我有一个显示自定义分类法中所有术语的循环。我还有图像字段,附加到自定义分类法。现在,我想在我的页面模板中显示图像:
<?php
/* Template Name: Služby */
get_header();
?>
<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>
<?php
get_footer();