Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

Also, if I change my operator to NOT IN, it searches the correct post type but excludes the category I want to search for.

Why would using a tax_query argument seemingly invalidate my post_type argument and instead include all post types but the one I wanted?

share|improve this question

1 Answer 1

Turned out to be a plugin conflict. I had turned off all plugins at one point to no noticeable benefit, but then turned a few back on so I could run some other things on the site I was working with.

The trouble was with the Easy Custom Content Types plugin (a very handy plugin) and I'm checking in with the developer of it. It looks like I may not have the latest version of it either so maybe he's already fixed it.

share|improve this answer
    
The problem is caused by a function in the plugin that helps to resolve taxonomy archive 404s. It has a couple of issues, and because of them, there is a setting to disable the function. Go to Content Types > Settings and check "Disable Taxonomy Archive Fix". –  Pippin May 11 '12 at 0:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.