Home › Forums › General Issues › Display featured images of selected taxonomy terms › Reply To: Display featured images of selected taxonomy terms
I came up with the following solution:
function custom_accreditation_logo () {
ob_start();
$queried_object = get_queried_object();
$post_id = $queried_object->ID;
$terms = wp_get_post_terms( $post_id, 'accreditations' );
//$terms = get_terms( array( 'taxonomy' => 'accreditations', 'hide_empty' => false ) );
echo '<div class="acc_logos">';
foreach ( $terms as $term ) {
$image = get_field('featured_image', 'accreditations_' . $term->term_id );
echo '<img src="' . $image['url'] . '" alt="' . $image['alt'] .'">';
}
echo '</div>';
$content = ob_get_clean(); // store buffered output content.
return $content;
}
add_shortcode( 'accreditatie_logos', 'custom_accreditation_logo' );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.