Hi,
I have a Country taxonomy then set a ACF image FLAG for each county.
In a elementor loop i try to display with a shorcode but this returns nothing, is it normal ?
$image = get_field('flag', 'country' . '_' . get_the_ID());
thanks
Hi @pipoulito
get_the_ID() would return a page/post ID, I believe you would need to return the taxonomy ID, assuming the image is set against the taxonomy
@jarvis Yes you are right !
Do you know how could i get the taxonomy id ?
thanks
Hi @pipoulito:
<?php
$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
$image = get_field('flag', 'country' . '_' .$term_id );
if( !empty( $image ) ): ?>
<img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />
<?php endif; ?>
Code’s untested