I have loop that displays only the direct children of a term on a taxonomy page. I also have image field, attached to custom taxonomy. Now, I want to display image in my page template:
<?php
$current_term_id = get_queried_object_id();
$taxonomyName = "car-brand";
//Could use ACF or basic custom field to get the "parent tax ID" dynamically from a page. At least that's what I would do.
$parent_tax_ID = $current_term_id;
$parent_tax = get_term($parent_tax_ID);
echo '<ul>';
$terms = get_terms( $taxonomyName, array( 'parent' => $parent_tax_ID, 'orderby' => 'slug', 'hide_empty' => false ) );
foreach ( $terms as $term ) {
echo '
<div class="am-ts-item">
<a href="' . get_term_link( $term ) . '">
<div class="am-ts-img">
<img src="">
<span>2004 - 2007</span>
</div>
<div class="am-ts-info">
<h2>' . $term->name . '</h2>
</div>
</a>
</div>
';
}
echo '</ul>';
?>
My image field: "am-brand-img"