Thank you for the prompt response. The below is the code that is used on a single.php page in the theme (i.e. within another post). $postarea is defined through a custom field. The filter works as intended. But if I check “Exclude from Search Results” in any one of the posts then it disappears from the results. Thank you in advance for the help.
// define query parameters based on attributes
$options = array(
‘post_type’ => ‘post’,
‘posts_per_page’ => -1,
‘relation’ => ‘AND’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘location’,
‘field’ => ‘slug’,
‘terms’ => $postarea,
‘include_children’ => true,
‘operator’ => ‘IN’,
),
),
);
$query = new WP_Query( $options );
// run the loop based on the query
if ( $query->have_posts() ):?>