WordPress.org

Ready to get started?Download WordPress

Forums

query 2 post types on one page (3 posts)

  1. Ellerbestyle
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

    http://codex.wordpress.org/The_Loop

    "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
    Member
    Posted 1 year ago #

    http://pastebin.com/fteayUh9

    Hope that works. I have never used pastebin before.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags