Hello!
I created a custom field of image type for my custom taxonomy. How can now display it in front-end?
My taxonomy is “author” for a book store, the custom field is the image of the author that i want to show in the Author page.
Thanks a lot
What version of ACF are you using?
// ACF >= 5.5.0
$queried_object = get_queried_object(); // gets the term
$post_id = 'term_'.$queried_object->term_id;
$image = get_field('image_field_name', $post_id);
// ACF < 5.5.0 - will also work on >= 5.5.0
$queried_object = get_queried_object(); // gets the term
$post_id = $queried_object->taxonomy.'_'.$queried_object->term_id;
$image = get_field('image_field_name', $post_id);
for more information see the section on getting field values from different objects on this page https://www.advancedcustomfields.com/resources/get_field/
Ok with this code i get the information, but how to show it in front end?
something like
if( $image ) {
echo wp_get_attachment_image( $image );
}
???
That depends on the return format of the image field. What do you have it set to return?