Custom Query, show grandchild pages… paginating?!
-
Hey guys,
I’ve been trying to retrieve a list of grandchild pages, using a
post_thumnail
to make a gallery of said pages. However, I wish this list to be limited to a comfortable amount per page.Having used successfully the code found here: https://www.ads-software.com/support/topic/query_posts-grandchildren-of-static-pages?replies=3
<?php $gen1_ids = 56; $gen2 = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent IN ($gen1_ids) AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC"); $gen2_ids = implode($gen2,', '); $gen3 = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent IN ($gen2_ids) AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC"); $gen3_ids = implode($gen3,', '); $args=array( 'post__in' => $gen3, 'post_type' => 'page', 'post_status' => 'publish', 'posts_per_page' => -1, // I wish to control the posts items listed 'caller_get_posts'=> 1 // I also wish to paginate ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { echo 'List of Pages grandchild pages of id 56' ; while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> <?php endwhile; } wp_reset_query(); // Restore global post data stomped by the_post(). ?>
I’m now struggling to paginate as I’m wanting to set the
posts_per_page
to a more manageable number.
<div class="pagination"> <?php echo paginate_links( ); echo $paged;?> </div>
(returns nothing)Having read: https://wordpress.stackexchange.com/questions/21181/custom-post-type-archive-page-set-posts-per-page-paginate I’m none the wiser how to resolve this issue.
Any ideas?
- The topic ‘Custom Query, show grandchild pages… paginating?!’ is closed to new replies.