Home › Forums › ACF PRO › Trying to display selected taxonomy terms and their images on home page. › Reply To: Trying to display selected taxonomy terms and their images on home page.
I figured this out. I totally misused the repeater field which caused an unnecessary headache.
Anyway, this is the code I used. It’s a modified version of this code – https://support.advancedcustomfields.com/forums/topic/query-custom-taxonomy-name-and-link-inside-repeater/
Hope this helps someone out.
<?php
// loop through the repeater
if (have_rows('catimg_repeater')) {
while (have_rows('catimg_repeater')) {
the_row();
$term = get_sub_field('choose_category');
$term_link = get_term_link($term);
$image = get_sub_field('choose_image');
$url = $image['url'];
$alt = $image['alt'];
?>
<a href="<?php echo $term_link; ?>"><img src="<?php echo $url ?>" alt="<?php echo $alt ?>" /></a>
<?php
} // end while have rows
}
?>
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.