Solved

WordPress - Add pagination to a list of Child pages.

Posted on 2009-07-01
1
1,265 Views
Last Modified: 2012-08-13
Hello,

I have a page where I'm pulling a list of child page titles/excerpts for that particular page. There are around 30 child pages for this particular page so I just want to display 10 child page titles/excerpts at a time with "Previous" and "Next" navigation buttons at the bottom of the page. The code listed below works fine but displays ALL of the child pages. Any Assistance is greatly appreciated.

Thanks



<!-- Start Code -->
<?php
$pageChildren = get_pages('child_of=' . $post->ID . '&exclude=' . $exclude_page );
if ( $pageChildren ) {
foreach ( $pageChildren as $pageChild ) {
$pageChild->post_title.'</h2>';
 
query_posts('page_id=' . $pageChild->ID);
 
if (have_posts()) : while (have_posts()) : the_post(); ?>
 
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="entry">
<?php the_excerpt('<p class="serif">Read the rest of this page »</p>'); ?>
 
<?php wp_link_pages(array('before' => '<p>Pages: ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
 
</div>
 
</div>
<?php endwhile; endif; ?>
 
<?php
}
}
?>
<!-- End Code -->

Open in new window

0
Comment
Question by:wattanabi2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
NovaRising earned 500 total points
ID: 24787258
You are going to have to manually limit the number of posts you want to display to a certain number.

http://www.wprecipes.com/how-to-define-how-many-post-to-display-per-page


This plugin is optional and can help you if you want numbers instead of next/previous.

http://www.catswhocode.com/blog/how-to-integrate-a-pagination-in-your-wordpress-theme


I pasted the code below that I think should work. You shouldn't have to add any "endif" tags or "endwhile" tags since you already have them. Let me know if I can help further.
For the First Step Find:
----------------------------------------
 
query_posts('page_id=' . $pageChild->ID);
 
if (have_posts()) : while (have_posts()) : the_post();
 
And Replace With:
-----------------------------------------
$page_num = $paged;
if ($pagenum='') $pagenum =1;
query_posts('page_id=' . $pageChild->ID . '&showposts=10&paged='.$page_num); ?>
               	<?php if (have_posts()) : ?>
		<?php while (have_posts()) : the_post(); ?>

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question