I’m not sure what the rest of your code looks like, but you are mixing up your $query
variable and you are not sending your $query
to the new instance of WP_Query
. Also, there is no need to send an array to the “terms” parameter if you are only using one term. Try this.
<?php
// Set the args
$args = array(
'tax_query' => array(
'relation' => 'AND',
array (
'taxonomy' => 'location',
'field' => 'slug',
'terms' => 'california',
),
array(
'taxonomy' => 'genre',
'field' => 'slug',
'terms' => 'comedy',
)
)
);
// Make a new instance of WP_Query
$query = new WP_Query();
// Make the query
$query->query($args);
// Test for posts
if($query->have_posts())
{
// Loop through posts
while($query->have_posts())
{
// Set up the post
$query->the_post();
global $post;
}
}
?>