Home › Forums › Front-end Issues › Display taxonomy image in WP_Query › Reply To: Display taxonomy image in WP_Query
Hey John, thanks for you answer. I tried but it results in nothing. My posts are well associated with a category and those categories have a “logo_image” in place. I think i’m dumb AF or it’s just because i’m a frontend guy, can you help me out a little bit more? You’d be my xmas angel! <3
<?php
$terms = wp_get_post_terms();
// args
$args = array(
'order' => 'DESC',
'orderby' => 'date',
'posts_per_page' => -1,
'post_type' => 'post',
);
// query
$posts_query = new WP_Query( $args );
?>
<?php if( $posts_query->have_posts() ): ?>
<?php while ( $posts_query->have_posts() ) : $posts_query->the_post(); ?>
<div class="swiper-slide">
<a href="<?php the_permalink(); ?>" class="c-card-article">
<div class="c-card-article__img mb-15">
<div class="c-card-article__overlay">
<i class="icon-arrow-right"></i>
<div><?php _e('Plus de détails', 'credo'); ?></div>
</div>
<?php
foreach ($terms as $term) {
$image = get_field('logo_image', $term);
}
?>
<?php the_post_thumbnail( 'large', array( 'class' => 'u-w-100' ) ); ?>
</div>
<p><?php the_title(); ?></p>
</a>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
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.