@wpfieldwork Yes!
That fixed things perfectly. I’ve been working through a PHP course and wanted to push myself with a taxonomy query in an ACF block. I could sort of see that the ID was required but couldn’t puzzle it out.
Thank you so much for your time and advice, you’ve made a dev very happy.
Thank you for your comment, context would have been useful @wpfieldwork!
The code is in a custom block. I’ve been trying to play around with where the ID is passed but haven’t found a solution yet…
Like so many problems, a weekend off and a fresh look solved things. My initial code must have had a error in it as fixing it turned out to be super simple:
<?php
$terms = get_field('featured_topics');
if( $terms ): ?>
<?php foreach( $terms as $term ):
?>
<h5 class="text-center"><?php echo esc_html( $term->name ); ?></h5>
<p><?php the_field('s_t_intro', $term); ?></p>
<a href="<?php echo esc_url( get_term_link( $term ) ); ?>"><?php echo esc_html( $term->name ); ?> blog posts</a>
<?php endforeach; ?>
<?php endif; ?>
Hopefully that might help someone in the future.
Thanks ACF-fan, that gives me a few ideas. Will carry on digging.
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.