I am trying to add an ACF variable to a WordPress query
I have an ACF taxonomy field (firm_types), it returns the term object.
My form is sending the term_id. I think the problem is that I am returning the taxonomy object, not specifically the term_id, somehow I need to make that the comparison
form (this displays correctly)
$terms = get_field('firm_types');
if( $terms ):
foreach( $terms as $term ):
$option .= '<option value="'.$term->term_id.'">';
$option .= esc_html( $term->name );
$option .= '</option>';
endforeach;
endif;
Search results page
$args = array(
'post_type' =>'companies',
'post_status' => 'publish',
'posts_per_page' => 100,
'meta_query' =>
array(
'relation' => 'AND',
array(
'key' => 'company_office_visibility',
'value' => "yes" ,
'compare' => '='
)
)
);
if (isset($final_architects_cat) && ($final_architects_cat != "") ) {
$args['meta_query'][] = array('key' => 'firm_types', 'value' => $final_architects_cat, 'compare' => '=');
}
$wp_query = new WP_Query( $args );
First question is, is the taxonomy field set up to save and load terms?