Home › Forums › Front-end Issues › Retrieve taxonomy based on ACF field. › Reply To: Retrieve taxonomy based on ACF field.
No worries, thanks for taking the time to look. It turned out my main issue was converting the array to a string, in case this is ever useful to anyone else… this worked
<?php
echo '<div class="row mb-5"><div class="col-12"><h3>History</h3></div>';
foreach($madein as $term)
{
$a = get_field('podcast_topic', 'shows_'.$term->term_id); // get the field array
$topicforuse = json_encode($a); // use json to convert to a string
if (strpos($topicforuse, 'history') !== false) { //check the string for a keyword
echo '<div class="col-6 col-md-3 col-xl-2 p-2"><a href="' . get_term_link( $term ) . '">';
echo wp_get_attachment_image( get_field('podcast_category_thumb', $term), 'thumbnail', false, array('class' => 'img-responsive rounded','style' => 'width:100%;height: auto; aspect-ratio: 1 / 1') );
echo '</a></div>';
}}
echo '</div>';
?>
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.