/ Published in: PHP
Show only children posts of a parent custom post type, not all child posts
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $loop = new WP_Query( array( 'post_type' => 'products', 'post_parent' => 0, 'posts_per_page' => 30, 'order' => 'ASC' ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="navigation"> <div class="content"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <a href="<?php the_permalink() ?>" class="hotspot" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('product-thumbnail'); ?></a> </div> </div> <?php endwhile; ?>
URL: http://stackoverflow.com/questions/8343544/query-only-parent-pages-in-custom-post-type-within-loop