WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] wp_query post_type argument choosing all post types except the one I want

[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
                    (
                        [0] => media_player
                        [1] => ada_slides
                        [2] => closings
                        [3] => staff
                        [4] => post
                        [5] => page
                    )
    
                [tax_query] => Array
                    (
                        [0] => 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.

Viewing 1 replies (of 1 total)
  • Ugh, it was a plugin problem. At one point I had turned off all plugins but then turned them back on. I must have done something inbetween then to make the problem more obvious.

    The culprit was East Custom Content Types. I’m bringing it up with the developer.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] wp_query post_type argument choosing all post types except the one I want’ is closed to new replies.