views:

27

answers:

1

I'm trying to add next and previous buttons to the static pages on my wordpress site.

I've been able to find some content on how to add these buttons to your blog post but haven't been able to find anything like this regarding static pages.

I'd like to add next and previous buttons to appear on the child pages within all the parent pages on my site, so you'd be able to use a link to navigate to the next/previous page located within the same parent.

Does anyone know how I could go about doing this or of any plugin that might help me out?

--

Thanks to songdogtech, I've almost got it, but I just having one problem.

It seems the next and previous links are working almost how I'd like but they are coming in in alphabetical order when I want to to match the order I've got my pages ordered in.

this is what I've tried but it doesn't seem to work

$pagelist = get_pages('child_of='.$post->post_parent.'sort_column=menu_order');

Seems I just figured it out was missing &... should look like this.

$pagelist = get_pages('child_of='.$post->post_parent.'&sort_column=menu_order');
A: 

This should work, from the Wordpress Codex (Next and Previous Links « WordPress Codex).

Exclude pages with parameters in get_pages: http://codex.wordpress.org/Function_Reference/get_pages

(Or this plugin http://wordpress.org/extend/plugins/next-page/):

<?php
$pagelist = get_pages('sort_column=menu_order&sort_order=asc');
$pages = array();
foreach ($pagelist as $page) {
   $pages[] += $page->ID;
}

$current = array_search($post->ID, $pages);
$prevID = $pages[$current-1];
$nextID = $pages[$current+1];
?>

<div class="navigation">
<?php if (!empty($prevID)) { ?>
<div class="alignleft">
<a href="<?php echo get_permalink($prevID); ?>"
  title="<?php echo get_the_title($prevID); ?>">Previous</a>
</div>
<?php }
if (!empty($nextID)) { ?>
<div class="alignright">
<a href="<?php echo get_permalink($nextID); ?>" 
 title="<?php echo get_the_title($nextID); ?>">Next</a>
</div>
<?php } ?>
</div>
songdogtech
thanks, just wondering if there's a way to exclude the parent directory from this? So if your in a section under a main parent page the next and previous links will only navigate to and from the pages contained under that parent.
Adam
Try excluding the parent pages with parameters in get_pages as added above.
songdogtech
Thanks I got it all figured out :)
Adam