Using tax_query changes my post_type query in my WP_Query arguments
-
I’m using a custom query to pull some posts from a custom post type. I’m having problems with it so I used print_r on my WP_Query object and I found something strange.
my query has these arguments:
'post_type' => 'event' ,'tax_query' => array( array( 'taxonomy' => 'event-categories' ,'field' => 'id' ,'terms' => 72 ,'operator' => 'IN' ) ) ,'order' => 'ASC' ); $query = new WP_Query( $args );
and when I remove the tax_query portion I get all my posts, but when I include it I get none. I’m positive I have more than one post with the taxonomy ID of 72. When I look at my print_r($query) with the post type in, I see this:
WP_Query Object ( [query_vars] => Array ( [post_type] => Array ( [0] => media_player [1] => ada_slides [2] => closings [3] => staff [4] => post [5] => page )
All of my post types are listed except for the one I wanted, event. If I take out tax_query from my args, it looks like this:
WP_Query Object ( [query_vars] => Array ( [post_type] => event [order] => ASC ...and so on
Why would using a tax_query argument seemingly invalidate my post_type argument and instead include all post types but the one I wanted?
- The topic ‘Using tax_query changes my post_type query in my WP_Query arguments’ is closed to new replies.