Using ACF i've added a custom image field to a particular set of custom post tags. The problem I have is that I cannot get the images to display. Yes, I have added an image to the tag and updated.
$term_id = 26;
$taxonomy_name = 'tags';
$termchildren = get_term_children( $term_id, $taxonomy_name );
foreach ( $termchildren as $child ) {
$term = get_term_by( 'id', $child, $taxonomy_name );
$tag_image = get_field('tag_image');
echo '<a href="?categories=' . $term->slug . '">'. $term->name . '</a>';
echo $tag_image; //this bit doesn't work :(
}
Fixed, the new code is:
<?php
$term_id = 26;
$taxonomy_name = 'tags';
$termchildren = get_term_children( $term_id, $taxonomy_name );
foreach ( $termchildren as $child ) {
$term = get_term_by( 'id', $child, $taxonomy_name );
$tag_image = get_field('tag_image', $term);
echo '<a href="?categories=' . $term->slug . '" class="one-third column">'. $term->name;
?>
<? if( !empty($tag_image) ): ?>
<img src="<? echo the_field('tag_image', $term); ?>" />
<?php endif;
echo '</a>';
}
?>
Resource for the fix was here http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/