I'm trying to do a query for a post with three terms in a custom taxonomy. Then, in the loop, I want to output just the posts with one of these terms:
$args = array(
'post_status' => array( 'publish' ),
'tax_query' => array(
array(
'taxonomy' => 'prr',
'field' => 'slug',
'terms' => ['proteger', 'respetar', 'remediar'],
),
)
);
$prr_query = new WP_Query( $args ); ?>
if ( $prr_query->have_posts() ) {
while ( $prr_query->have_posts() ) {
$prr_query->the_post();
if (has_term('proteger')) {
the_title();
}
}
}
wp_reset_postdata();
It does not work.
If I do a loop without conditional, it works:
if ( $prr_query->have_posts() ) {
while ( $prr_query->have_posts() ) {
$prr_query->the_post();
the_title();
}
}
wp_reset_postdata();
If I do a var_dump($prr_query)
I get this:
I can see, in this query, that post objects do not includes term list.
How can I output just the posts that has a specific term?