Weird WP_Query issue – meta_query not being added to query_vars
-
Hi everyone, it’s my first time posting here, let me know if I am doing something wrong ??
I have a very puzzling issue with WP_Query. I am pretty sure it’s not a bug, but I am running out of ideas. I’ve been using WP_Query with meta_query for ages now and on one theme I’m working on it’s producing weirdness, here’s what’s up, through an example:
$args = array( 'post_type' => 'property', 'meta_query' => array( array( 'key' => 'mykey', 'value' => 'myvalue', 'compare' => '=' ) ) ); $stupid = new WP_Query( $args );
The issue is that the meta_query is not used at all. If you print out $stupid it should be added to query_vars but it is shown as an empty array:
[query_vars] => Array ( [post_type] => property [meta_query] => Array ( ) [error] => [m] => 0 [p] => 0 [post_parent] => .... etc
I have tried doing this every which way, copy-pasting from the codex, using the set() method, using query_posts after the fact, nothing works.
As I mentioned, I’ve used this hundreds of times before, on 3.5.2 as weel, so I doubt it is a bug. It must be something theme-related, anyone have any ideas what it could be?
I have no custom ‘pre_get_posts’ stuff going on or anything else of that nature. I’ll wade through the source code for WP_Query but if anyone has any ideas in the meantime I would be super thankful!
Thank you ??
Daniel
- The topic ‘Weird WP_Query issue – meta_query not being added to query_vars’ is closed to new replies.