Posted By

i-am-andy on 01/10/12


Tagged

wordpress


Versions (?)

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


 / Published in: PHP
 

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

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

  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; ?>

Report this snippet  

You need to login to post a comment.