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.

If I remove 'relation' and one of the taxonomy arrays the corresponding posts are returned for each taxonomy but when I add the 'relation' = 'AND' no posts are returned. Is there a problem in my $args?

$queried_object = get_queried_object(); 
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
$term_slug = $queried_object->term_slug;
$term_name = $queried_object->term_name;

$args = array(
    'post_type' => 'listing',
    'posts_per_page' => '10',
    'post_status' => 'publish',
    'tax_query' => array(
        'relation' => 'AND',
            'taxonomy' => $taxonomy,
            'field'    => 'id',
            'terms'    => array($term_id),
            'operator' => 'IN'
            'taxonomy' => 'listings_categories',
            'field'    => 'slug',
            'terms'    => array('mortgage-loans'),
            'operator' => 'IN'
    //'orderby' => 'meta_value',
    //'meta_key' => 'listing_is_featured',

share|improve this question
Don't use query_posts. Go and have a look at this post –  Pieter Goosen May 3 '14 at 3:22

Your Answer


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

Browse other questions tagged or ask your own question.