Show only children posts of a parent custom post type, not all child posts


/ Published in: PHP
Save to your folder(s)

Show only children posts of a parent custom post type, not all child posts


Copy this code and paste it in your HTML
  1. <?php $loop = new WP_Query( array( 'post_type' => 'products', 'post_parent' => 0, 'posts_per_page' => 30, 'order' => 'ASC' ) ); ?>
  2.  
  3. <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
  4.  
  5. <div class="navigation">
  6. <div class="content">
  7. <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
  8. <a href="<?php the_permalink() ?>" class="hotspot" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('product-thumbnail'); ?></a>
  9. </div>
  10. </div>
  11.  
  12. <?php endwhile; ?>

URL: http://stackoverflow.com/questions/8343544/query-only-parent-pages-in-custom-post-type-within-loop

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.