WordPress.org

Ready to get started?Download WordPress

Forums

One post per category in custom post type (1 post)

  1. WereAllThieves
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by WereAllThieves
  • This topic is not resolved
  • WordPress version: 3.3.1