Home › Forums › Front-end Issues › Custom Post Taxonomies and ACF › Reply To: Custom Post Taxonomies and ACF
I reworked my template a bit, but still see the same error:
<?php get_header(); ?>
<h1 class="entry-title"><?php single_term_title(); ?></h1>
<div class="archive-meta"><?php if ( '' != the_archive_description() ) { echo esc_html( the_archive_description() ); } ?></div>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article class="post">
<?php if ( has_post_thumbnail() ) : ?>
<div class="thumb">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a>
</div>
<?php endif; ?>
<div class="content">
<h3><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<p class="excerpt-entry"><?php echo strip_tags( get_the_excerpt() ); ?></p>
</div>
</article>
<?php endwhile; endif; ?>
<h2>Actors</h2>
<?php $get_actors = get_field('actors'); ?>
<?php if( $get_actors ): ?>
<ul>
<?php foreach( $get_actors as $actors ): ?>
<li><a href="<?php echo esc_url( get_term_link( $actors ) ); ?>"><?php echo esc_html( $actors->name ); ?></a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php get_footer(); ?>
When I have nothing linked to the taxonomy, the ACF taxonomy data displays (example: https://a.cl.ly/X6uKqWrL).
In the db query, I see the the following:
SELECT t.term_id
FROM wp_terms AS t
INNER JOIN wp_term_taxonomy AS tt
ON t.term_id = tt.term_id
WHERE tt.taxonomy IN ('actor')
AND t.term_id IN ( 403,404,284 )
ORDER BY t.name ASC
Those term IDs are correct. The full display of DQ queries also looks accurate (example: https://a.cl.ly/WnumRzdq).
I take a single blog post, assign the shows taxonomy for “Broadchurch” for example (example: https://a.cl.ly/6qubm9kN) and save the post. When I refresh the taxonomy archive page, there are no queries at all for ACF, as shown here: https://a.cl.ly/P8u2ZvgJ.
My ACF setup for the field is: https://a.cl.ly/GGu7qZL8 and the location rules are: https://a.cl.ly/8Luq2mdn
I suspect that WP is overriding the ACF query entirely, or somehow preventing it from ever running in this instance where a post has a bunch of terms applied to it, but the term itself also has a term applied to it.
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!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG
— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.