Sillybean
Next Page
This plugin provides shortcodes and template tags for next/previous navigation in pages.
Download it at wordpress.org »
Report problems using the support forum »
If you’d rather not deal with the overhead of a plugin, here’s the condensed code for your page template file:
<?php
$pagelist = get_pages('sort_column=menu_order&sort_order=asc');
$pages = array();
foreach ($pagelist as $apage) {
$thepages[] += $apage->ID;
}
$current = array_search($post->ID, $thepages);
$prevID = $thepages[$current-1];
$nextID = $thepages[$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><!-- .navigation -->
You can emulate Drupal’s book feature and include a link to the page parent as well:
<div class="aligncenter"> <a href="<?php echo get_permalink($post->post_parent); ?>" title="<?php echo get_the_title($post->post_parent); ?>">Up one level</a> </div>
Version 1.2 adds an option to exclude pages by ID. You can simply add the exclude parameter to the get_pages() function in your template code:
$pagelist = get_pages('sort_column=menu_order&sort_order=asc&exclude=6,21,47');
141 comments
Sharing this post? The short URL is: http://sillybean.net/?p=2275




Sorry. Cannot help you with that. Have not encountered that problem so far. Could be a browser issue, maybe?
It’s not a browser issue that I can see. I’ve tried it on Firefox, Safari and Opera so far and all three have the same problem.
Thanks for trying to help.
It is not a browser issue. I think I’ve identified the problem, but I’ve been swamped at work today and haven’t had time to test it. Tracy, try changing the $page variable to something else. Apparently it’s a global in WP, which I’d never noticed, and I’m pretty sure that’s the problem.
That’s funny, Stephanie, I was just identifying that as the problem! Yeah, it’s used extensively in the post-template.php file.
I changed both the $pages and $page variables and it worked.
Thanks for spending the time to troubleshoot!
@Tracy what did you change them to? Will be nice to know for future reference in WP.
@Ed I just changed them to $projectpage and $projectpages respectively because those names mean something to my specific pages. You can change them to whatever you want to though. Just make sure to change the name of all instances of each variable. (I didn’t change the $pagelist variable.)
I’ve just updated this page with better variables. Thanks for pointing out the problem, Tracy!
Thanks @Stephanie and @Tracy for all the help.
Glad to have a problem that could help everyone! Thanks @Stephanie for your help.
Thank you for sharing it with us. This way we all get to learn new things.
I’ve made 2 changes to this plugin:
I too ran into the same issue as what Derek states an I think (imho) this in an improvement:
Slightly changed Code
The other thing is that I’ve removed the echos from the template tags. Lines 244,248,252 as I want to move the navigation outside the loop. You can put them back in if you wish.
Hope this helps someone. Excellent plugin!
Thanks a lot Steph. Just upgraded it today. Will let you know if I run into any problems.
Are you using the script in your HTML to activate it?
Hello, I recently upgraded from v. 1.3 to 1.4, and now the previous and next links appear at the top of the page and there’s a weird rendering where the body text wraps around the previous and next links. Check it out:
http://www.naborsapts.org/residents/co-op-handbook/home-equity-loan-or-line-of-credit/
I’m using the shortcodes at the end of the text.
Any help to fix the glitch appreciated.
Cheers!
@Eduardo I do not see what you seem to say. I visited the website.
The previous and next links used to be after the text of the page, which is where I want it. Now, after upgrading to 1.4, the links appear after the entry title, but before the text. Also, notice how the beginning of the text is squeezed (wraps around) the previous and next links. I hope this makes sense.
Can you post a link to the page so I know where to look?
Thanks.
Here’s a sample page:
http://www.naborsapts.org/residents/co-op-handbook/home-equity-loan-or-line-of-credit/
You can specify where you want the tags. Up or down on the page. Think there is an option in the settings to do it.
Nope, The settings page has no such options. I think I’ll just have to go back to version 1.3.
What version of WP are you using?
Version 2.9.2.
Then you should not have a problem. Could be a scripting issue. Who do you host with?
The problem began when I upgraded from v. 1.3 to v. 1.4. So the logical conclusion is that something was changed in the plug-in code from 1.3 to 1.4. I’ll just go back to v. 1.3 and hopefully that’ll solve the problem. But thanks for trying, Ed!
See if that works. It should I think. Your script is messed up somewhere.
Similar problem here – I have put the [previous] and [next] tags at the bottom of each of the site’s history pages but now the links appear at the top.
Andrew
When I had the issue it was the script in my template that was over-riding the position of the text. Do you have any other modules in WP installed like WP Page Navi or something? Check your template index file too for scripting conflicts.
Hi
Im using the shortcodes with next page plugin. It doesnt matter where I put the short codes they always show up at the top of the page above all content. Is there a way of making the next and previous links show up after the content? I can see that this issue has possibly started since the 1.4 release? Where can I get version 1.3 to test and see if that solves it?
Thanks
Not sure about the older version. It should be there on the site. Did you save a copy on your machine?
Hi
I found the older version and it works perfectly. The shortcode tags go where I put them and don’t just show up at the top of the page. I’ll be using 1.3 until 1.4 is fixed. Good plugin.. thanks
Just as I suspected. I’ll be switching back to version 1.3 as well. Thanks Spiritualight!
Sorry could not be of much help. Reverting back to the old version should help for now. The new one had some neat features.
I’m using the plugin for a site which has kind of a storyline.
The parent pages are only container pages, containing two to ten subpages. These parent pages should not come up in the navigation. But when I enter those ID’s, no page whatsoever comes up because also the childpages are excluded.
So:
A
a1
a2
a3
B
b1
b2
b3
Pages A and B are empty. The navigation should go from a3 to b1. How can I do this?
The links are not taking me to the next or previous page, just reloading the page I am already on.
I would also like to use an arrow image to change pages instead of text. Can I do that??
Take a look at my page!!
http://www.adaytoremembervideos.com/david/
THANKS
You can use arrows if you wish. You have to upload their image and use the appropriate script to do so.
I’d like to put my question here for a second time, because the site is now online and I don’t know how to fix my problem (link: http://sillybean.net/code/wordpress/next-page/comment-page-2/#comment-22121). The problem is that the backlinks to previous pages is not working in my case. They link to the parent page which is empty, and than nothing happens.
You can see what I mean here: http://www.onschuldiggevangen.nl/wat-ging-aan-pim-overziers-dood-vooraf/het-verhaal-van-pim-overzier
You might need to use an older version of the plugin as it seems there might be bugs in the new one.
i am having a few problems with this plugin. When i add [previous] [parent] and [next]. [previous] and [parent] are grouped together on the same line while [next] is down a line and looks correct. Also i am trying to skip a sub-parent page but not skip the pages under the sub-parent page. is there a way to do that?
I am not exactly sure of what you mean.
the second problem i am having is the same problem that Jack is having. the first problem i said is shown in this picture http://i129.photobucket.com/albums/p224/skatepunk476/Untitled-20.jpg
any idea about my problem? http://i129.photobucket.com/albums/p224/skatepunk476/Untitled-20.jpg
Have you tried switching to an older version of the plugin?
I tried version 1.3 and 1.2. Both don’t work.
In my example above (http://sillybean.net/code/wordpress/next-page/comment-page-2/#comment-22121) I can go from a3 to b1 with no problem, but the backlink from b1 to a3 doesn’t work, because it wants to show B, which is empty.
I am not sure if the plugin is having problems with the alphanemeric characters you are using. Probably.
Those numbers were just to illustrate the problem I’m having
. In reality those are just titles of pages: http://www.onschuldiggevangen.nl/wat-ging-aan-pim-overziers-dood-vooraf/het-verhaal-van-pim-overzier
What version of WP are you using? It is working fine for me. What browser are you using?
Version 2.9.2.
I’m also using the plugin ‘redirect parent to first child’, but when I disable that plugin, I can go back from b1 to a3 through B, but B is empty. So before getting to page a3 I have to navigate paste an empty page. And I was using this plugin because when I click on parent page B, I want to see b1, and not B, because that’s only a placeholder for the subpages.
I hope you see my ‘problem’.
And I’m using Firefox, latest version. I forgot to mention that
I am using IE 8.0 and it was working fine there.
Strange. Google Chrome gives me the same problem. I wonder if I made clear enough what my problem is
I can’t imagine it has something to do with what browser one uses.
The reason I suspected the browser was because I have seen it make a difference in reading HTML code.
Do you think there can be some kind of fix for this? I mean, Internet Explorer is still the browser that is known to be not always correct in handling code and css, no matter what version.
Attach the code you are using as a text document. I will try to fix it for you.
i am not using any different code
The code:
http://www.spoenk.nl/public/page.txt
The rest is all inside the plugin.
Also: http://www.spoenk.nl/public/parent_to_first_child.txt
because I’m using that for the direct link from parent to first child, but like I said, it didn’t have any effect disabling that plugin.
Is this what you need?
Will let you know of the outcome after I test it out myself.
Tested it myself in IE version 8, and it’s not working.
im still having the same problem
http://i129.photobucket.com/albums/p224/skatepunk476/Untitled-20.jpg
The code might need to be looked at.
Hello!
Nice plugin and useful by the way… I need to navigate between custom post types. Can this be done?
Thank you!! :-)
Not at the moment, Xoxo. Good idea, though.