[Resolved] wp_query post_type argument choosing all post types except the one I want
I have a custom query:
$args = array( 'post_type' => 'event', 'tax_query' => array( array( 'taxonomy' => 'event-categories', 'field' => 'id', 'terms' => 72 ) ) ); $query = new WP_Query( $args );
It is not returning any results. I am POSITIVE there is an event post in the taxonomy with an id of 72. When I print $query I see this as part of the object:
WP_Query Object ( [query_vars] => Array ( [post_type] => Array (  => media_player  => ada_slides  => closings  => staff  => post  => page ) [tax_query] => Array (  => Array ( [taxonomy] => event-categories [field] => id [terms] => 72 ) )
Why in the world would it EXCLUDE the one post type I wanted to include? what could possibly make that happen? I tried using wp_reset_query and wp_reset_post right before the query in case something had been altered, but no change.
Is it possible to mess up my filters somehow? I don’t know how it would have happened. Any ideas? Any at all?
If I change my tax_query to include ‘operator’ => ‘NOT IN’ then the correct post type is being grabbed but then I’m not getting the taxonomy I want. If I take out the tax_query, I get my event post type too.
- The topic ‘[Resolved] wp_query post_type argument choosing all post types except the one I want’ is closed to new replies.