Title: 2 values for custom fields
Last modified: August 21, 2016

---

# 2 values for custom fields

 *  [imagenparaweb](https://wordpress.org/support/users/imagenparaweb/)
 * (@imagenparaweb)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/2-values-for-custom-fields/)
 * Hi there..
 * How can I show something if a custom field has a certain name OR another certain
   name.
 * Something like these:
 * If custom field is equal to “name1” or “name2” then show this…
 * Can anyone post the correct code for this?
 * Please!! thanks.

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/2-values-for-custom-fields/#post-4726944)
 * I think this will work (untested):
 *     ```
       $args = array(
       	'post_type' => 'post', // Put your post type here
       	'meta_query' => array(
       		'relation' => 'OR',
       		array(
       			'key' => 'name1',
       		),
       		array(
       			'key' => 'name2',
       		)
       	)
       );
       $query = new WP_Query( $args );
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘2 values for custom fields’ is closed to new replies.

## Tags

 * [condition](https://wordpress.org/support/topic-tag/condition/)
 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/2-values-for-custom-fields/#post-4726944)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
