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!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 21, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.