One post per category in custom post type
I searched the forums, but found no solution to this problem:
I am running the MarketPress plugin, which creates products inside of a ‘product’ custom post type. I’d like to run a loop that returns 1 post per category in the ‘product’ custom post type. I have no way of knowing how many categories the client will be adding or subtracting, so the category filter in the loop will have to be dynamic.
Here is my loop so far:
<?php query_posts('post_type=product&orderby=rand'); if (have_posts()) : while (have_posts()) : the_post(); ?> <h6><?php the_title(); ?></h6> <?php endwhile; wp_reset_query(); ?> <?php else; ?> <h6>No products found</h6> <?php endif; ?>
Thanks in advance for the help.
- The topic ‘One post per category in custom post type’ is closed to new replies.