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

  • Now Update my code is work but why this code show all i need display only primary just one categories.

    	<?php 
    		$tax = 'company_categories';
    		$terms = get_terms( $tax, $args = array(
    		  'hide_empty' => false, // do not hide empty terms
    		));
    		
    		
    		foreach( $terms as $term ) {
    		
    			$term_link = get_term_link( $term );
    			$image = get_field('company_profile', 'company_categories_' . $term->term_id );
    		
    			if( $term->count > 0 ) {
    			   echo '<a href="' . esc_url( $term_link ) . '">';
    				echo "<img src='" . $image['url'] . "' height='130' width='150'> ";     
    				echo $term->name .'</a>';
    		
    			} elseif( $term->count !== 0 ) {
    				echo '' . $term->name .'';
    				
    			}
    		}
    				
    ?>