Title: set multiple values for a single parameter in get_posts
Last modified: August 20, 2016

---

# set multiple values for a single parameter in get_posts

 *  [kanika](https://wordpress.org/support/users/kanikawordpresscom/)
 * (@kanikawordpresscom)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/set-multiple-values-for-a-single-parameter-in-get_posts/)
 * Hi,
 * I donot know where this question belongs so kindly excuse me if it’s in the wrong
   forum!
 * My problem:
    I am retrieving posts through the get_posts function as:
 *     ```
       <?php
       global $post;
       $args = array( 'numberposts' => 2, 'offset'=> 0, 'post_type' => 'webcast');
       $myposts = get_posts( $args );
       foreach( $myposts as $post ) :	setup_postdata($post);
       $p_ID = get_the_ID();
       ?>
       ```
   
 * I want to say now that the **meta_value** parameter should be equal to either**
   XYZ** or **ABC**
 * How do I do that?

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/set-multiple-values-for-a-single-parameter-in-get_posts/#post-2880674)
 * [http://codex.wordpress.org/Function_Reference/WP_Query#Custom_Field_Parameters](http://codex.wordpress.org/Function_Reference/WP_Query#Custom_Field_Parameters)
 *  Thread Starter [kanika](https://wordpress.org/support/users/kanikawordpresscom/)
 * (@kanikawordpresscom)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/set-multiple-values-for-a-single-parameter-in-get_posts/#post-2880682)
 * It could help if the parameter could negated as in
 * meta_value <anything but> ‘Live’
 * Is it possible?
 * Thanks,
    Kanika.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/set-multiple-values-for-a-single-parameter-in-get_posts/#post-2880690)
 * Try it with this [untested]:
 *     ```
       $args = array(
               'posts_per_page' => 2,
               'post_type' => 'webcast',
        	'meta_query' => array(
        		array(
        			'key' => 'yourmetakey',
        			'value' => array('XYZ', 'ABC'),
        		)
        	)
         );
        $myposts = get_posts( $args );
       ```
   
 *  Thread Starter [kanika](https://wordpress.org/support/users/kanikawordpresscom/)
 * (@kanikawordpresscom)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/set-multiple-values-for-a-single-parameter-in-get_posts/#post-2880796)
 * Thanks,
 * That helped a lot! What worked for me was:
 *     ```
       //...code
                      'meta_query' => array(
                      'relation' => 'OR',
       		array(
       			//code
       		),
       		array(
       			//code
       		)
       )
       ```
   
 * as given on the link u provided.
 * I just have one more question. If I want to override the order_by according to
   the ‘meta_value’ parameter? As in, first we have all posts with meta_value ‘XYZ’
   and then with ‘ABC’
 * Thanks,
    Kanika.
 *  Thread Starter [kanika](https://wordpress.org/support/users/kanikawordpresscom/)
 * (@kanikawordpresscom)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/set-multiple-values-for-a-single-parameter-in-get_posts/#post-2880799)
 * Ordering by Date has temporarily solved the problem. (Per chance) But i’d still
   like to get an answer to this one.
 * Thanks,
    Kanika.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/set-multiple-values-for-a-single-parameter-in-get_posts/#post-2880811)
 * > As in, first we have all posts with meta_value ‘XYZ’ and then with ‘ABC’
 * Try it with two loops (get_posts), one for ‘XYZ’ and one for ‘ABC’.
 *  Thread Starter [kanika](https://wordpress.org/support/users/kanikawordpresscom/)
 * (@kanikawordpresscom)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/set-multiple-values-for-a-single-parameter-in-get_posts/#post-2880812)
 * Oh, ok. Thought it could be clubbed into one.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘set multiple values for a single parameter in get_posts’ is closed to
new replies.

## Tags

 * [get_posts](https://wordpress.org/support/topic-tag/get_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 3 participants
 * Last reply from: [kanika](https://wordpress.org/support/users/kanikawordpresscom/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/set-multiple-values-for-a-single-parameter-in-get_posts/#post-2880812)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
