query 2 post types on one page (3 posts)

  1. Ellerbestyle
    Posted 4 years ago #

    I am currently doing a small e-commerce site and I have 2 different post types to separate 2 different products. These will have there own pages but I want to be able to make a page that both sets of products all be visible. I have the code for one post type to show up but don't know how to get 2.

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

  2. bythegram
    Posted 4 years ago #


    "If you need to keep the original query around, you can create a new query object."

    <?php $my_query = new WP_Query('post_type=product2&posts_per_page=10'); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
      <!-- Do post type 2 stuff... -->
    <?php endwhile; ?>

    I hope that helps. If not use post bin and paste a link to your code and I'll have a closer look.

  3. Ellerbestyle
    Posted 4 years ago #


    Hope that works. I have never used pastebin before.

Topic Closed

This topic has been closed to new replies.

About this Topic