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 (  => media_player  => ada_slides  => closings  => staff  => post  => 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.