Support

Account

Home Forums General Issues wp_query by ACF taxonomy term_id

Helping

wp_query by ACF taxonomy term_id

  • 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?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.