Support

Account

Home Forums General Issues How to taxonomies and display taxonomy acf image only primary Reply To: How to taxonomies and display taxonomy acf image only primary

  • Update now finally but i need show only primary someone can help?

    <?php 
    
    $tax = 'company_categories';
    
    $types = get_terms( $tax, $args = array(
        'hide_empty' => false,
        'post_type' => 'company',
        'post_status' => 'publish',
    	'orderby'       => 'name',
    	'order'         => 'asc',   
    ) );
    
    foreach($types as $type) {
    	$term_link = get_term_link( $type );
        $image = get_field('company_profile', 'company_categories_' . $type->term_id . '' );
        
        if ( has_term( $type->term_id, 'company_categories') ) {
        	echo '<a href="' . esc_url( $term_link ) . '">';
        	echo "<img src='" . $image['url'] . "'  width='150'> ";
            //break;
    		//unset($term);
        }
    }
    ?>