Home › Forums › General Issues › Query in a taxonomy field › Reply To: Query in a taxonomy field
Nevermind, I find a way.
Here is my code in case someone would do it:
<?php
$terms = get_field('categories_a_afficher', 'option');
if( $terms ): ?>
<?php foreach( $terms as $term ): ?>
<div class="category_list">
<h2 class="fond">
<?php echo $term->name; ?>
</h2>
<a href="<?php echo get_term_link( $term ); ?>">
<?php _e( 'View all posts from', 'twentyeleven' ); ?> <strong><?php echo $term->name; ?></strong>
</a>
<!-- Here the query begin -->
<?php query_posts( 'showposts=2&order=DSC&cat=' . $term->term_id . ''); if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; endif; wp_reset_query(); // On ferme la boucle ?>
<?php //echo $term->term_id; ?>
</div><!-- .category_list -->
<?php endforeach; ?>
<?php endif; ?>
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.