?
Solved

WordPress - Add pagination to a list of Child pages.

Posted on 2009-07-01
1
Medium Priority
?
1,288 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 2000 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
This article discusses how to create an extensible mechanism for linked drop downs.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
Suggested Courses

764 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