• Resolved coderdj412

    (@coderdj412)


    I am attempting to query a couple taxonomies via a custom post type: venues.

    Using the example, I came up with this query but, it comes up empty:

    $args = array(
    	'post_type' => 'venue',
    	'tax_query' => array(
    		array(
    			'taxonomy' => 'venue_type',
    			'field'    => 'slug',
    			'terms'    => array('bar', 'club'),
    		),
    	),
    );
    $query = new WP_Query( $args );

    But, if I use this, I get results:

    $args = array(
    	'venue_type'    => 'bar', // Will not accept arrays and I need multi
    );
    $query = new WP_Query( $args );

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m not seeing any issues in your query. It’s sort of retarded but you could probably place each term argument in it’s own taxonomy array to avoid arrays passed to ‘terms’.

    But there’s no reason you should need to do that. Try hooking the ‘posts_request’ filter to examine the resulting SQL query. Something’s wrong with how it’s built, what that is could be a clue to a solution.

    Thread Starter coderdj412

    (@coderdj412)

    For some reason I must have switched the syntax and it wasn’t an array of an array and that’s why it wasn’t working. Finally fixed it and now its working.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WP_Query empty when using tax_query’ is closed to new replies.