I know this topic has been drummed to death and I apologise in advance but I am struggling to pull images from an image field assigned to tags.
https://gyazo.com/c9a41aa51931ecae4b5724f094de55c5
https://gyazo.com/5cda4a6945f914e041841b184729eefb
Each post tag has an image attached and I am trying to display the image within the loop. Posts do not contain more than one tag each.
I have tried various ways but the image src is always blank.
What would be the best way to tackle this?
There really isn’t enough information here. What code are you using to get/output the image field value?
I got it working with
add_action('generate_after_entry_title','gabster_view_logo' );
function gabster_view_logo() {
if ( function_exists( 'get_field' ) ) {
$tag = get_the_tags();
$term_id = $tag[0]->term_id;
$term = get_term( $term_id );
$image = get_field( 'view_logo', $term );
}
if (is_home() || is_archive()) {?>
<div class="view-logo"><img src="<?php echo $image; ?>" /></div>
<?php
}
}
Output
https://gyazo.com/ccf55b46b8c06416cb2d3c9cbe3cbfb4