Title: pre_get_posts meta_query nested array not working
Last modified: August 21, 2016

---

# pre_get_posts meta_query nested array not working

 *  [wendallsan2](https://wordpress.org/support/users/wendallsan2/)
 * (@wendallsan2)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/pre_get_posts-meta_query-nested-array-not-working/)
 * In my pre_get_posts function, setting the meta_query returns no results if it
   is a nested array. It works fine with a single (non-nested) array passed, but
   this is not how the documentation explains this feature and I actually do need
   to to filter with multiple meta_queries.
 * This works, even though according to the documentation it should not, as I am
   not setting the meta_query to a nested array:
 *     ```
       $meta_query = array( 'key' => 'author', 'value' => $member_ids, 'compare' => 'IN' );
       $query->set('meta_query', $meta_query);
       ```
   
 * This does not work (returns no results, even though I have posts that match both
   meta_query criteria):
 *     ```
       $meta_query = array();
       $meta_query[] = array( 'key' => 'author', 'value' => $member_ids, 'compare' => 'IN' );
       $meta_query[] = array( 'key' => 'mpl_pal_share_pal', 'value' => 1 )
       $query->set('meta_query', $meta_query);
       ```
   
 * This also does not work (this is the same thing as the first example above, which
   does work, except now it is nested in another array, which is how the documentation
   says it needs to be):
 *     ```
       $meta_query = array();
       $meta_query[] = array( 'key' => 'author', 'value' => $member_ids, 'compare' => 'IN' );
       $query->set('meta_query', $meta_query);
       ```
   
 * Again, I expect this last example should work exactly like the first example,
   in that it has the same exact meta_query, and the only difference is that it 
   is nested in an array. According to the documentation ([http://codex.wordpress.org/Class_Reference/WP_Query](http://codex.wordpress.org/Class_Reference/WP_Query))
   the meta_query needs to be a nested array, but this is absolutely not working
   for me. Any nested array return no results. If it is not a nested array, it works
   great, but I then cannot query using multiple meta_queries, which is what I need.
   Any help?

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

 *  [Ross Wintle](https://wordpress.org/support/users/magicroundabout/)
 * (@magicroundabout)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/pre_get_posts-meta_query-nested-array-not-working/#post-4564580)
 * I seem to be struggling with this too. Do you know if it was logged as a bug 
   or anything? Seems to be no response!
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/pre_get_posts-meta_query-nested-array-not-working/#post-4564581)
 * If you require assistance then, as per the [Forum Welcome](http://codex.wordpress.org/Forum_Welcome#Where_To_Post),
   please post your own topic instead of tagging onto someone else’s topic.
 * I am now closing this 4 month old topic as it references an older version of 
   WordPress.

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

The topic ‘pre_get_posts meta_query nested array not working’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/pre_get_posts-meta_query-nested-array-not-working/#post-4564581)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
