Support

Account

Home Forums Front-end Issues Get custom taxonomy term image field

Solved

Get custom taxonomy term image field

  • I have loop that displays all terms from custom taxonomy. I also have image field, attached to custom taxonomy. Now, I want to display image in my page template:

    <section id="sluzby" class="section--padding" style="background: #eff1f5;">
        <div class="container">
            <div class="row">
    
    			<?php		
    			$terms = get_terms( array( 'taxonomy' => 'sluzba', 'hide_empty' => false ) );
    			$term_image = get_field( 'tax_image' );
    					
    			foreach ( $terms as $term ) : ?>
    			
    				<div class="col-lg-4 col-md-6">
    					<div class="product product-zoom product--card">
    						<div class="product__thumbnail">
    
    							<?php //if ( $term_image ) : ?>
    
    								<img src="<?php echo $term_image['url']; ?>" alt="Slu┼żba <?php echo $term->name; ?>">
    
    							<?php //endif; ?>
    
    						</div>
    
    						<div class="product-desc">
    							<h4 class="text-center mb-2"><?php echo $term->name; ?></h4>
    						</div>
    					</div>
    				</div>				
    			
    			<?php
    			endforeach
    			?>
    			
            </div>
        </div>
    </section>
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.