Home › Forums › Backend Issues (wp-admin) › Multiple Categories Loop (Taxonomy) › Reply To: Multiple Categories Loop (Taxonomy)
I rewrote my code to use WP_Query but unfortunately this method returns all posts instead of posts assigned to a specific category.
<?php
$args = array(
'post_type' => 'cars',
'posts_per_page' => -1,
'taxonomy' => 'car_category',
);
$the_query = new WP_Query( $args ); ?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post();?>
<a href="<?php the_permalink(); ?>">
<?php echo the_post_thumbnail(''); ?>
</a>
<?php endwhile; ?>
<?php else : ?>
<p>Sorry, no products found.</p>
<?php endif; ?>
<?php wp_reset_postdata() ?>
<?php wp_reset_query() ?>
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.