Best practice for multiple queries on page

WP_Query can handle all of these cases. See the section on handling multiple taxonomies.

$this_cat="interviews";
$this_tag = 'angelina-jolie';

$args = array(
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'category',
            'field' => 'slug',
            'terms' => $this_cat
        ),
        array(
            'taxonomy' => 'post_tag',
            'field' => 'slug',
            'terms' => $this_tag
        )
    )
);
$interviews = new WP_Query( $args );

while( $interviews->have_posts() ):
    $interviews->the_post();
    // normal loops stuff
endwhile;

Leave a Comment