
Download Next Page, Not Next Post at WordPress.org
Out of the box WordPress does a magnificent job of handling navigation between next & previous posts. It doesn’t do too great of a job handling navigation between sibling pages. We needed a solution to allow users to easily switch between these pages. After much searching and testing, it was clear that there wasn’t a good solution to this dilemma.
Our first “official” WordPress plugin “Next Page, Not Next Post” handles that without too much trouble.
When a user is viewing page B, we create links to A & C. When on C, they get B & D and so on.
This plugin gives you two new functions, next_page_not_post($anchor_text, $loop, $getPages) & previous_page_not_post($anchor_text, $loop, $getPages). Each function has three simple options.
It’s as simple as echo’ing the functions in your page:
<?php echo next_page_not_post(); ?> <?php echo previous_page_not_post(); ?>
<?php
$nextPage = next_page_not_post('Next Page', 'true', 'sort_column=post_date&sort_order=desc');
$prevPage = previous_page_not_post('Previous Page', 'true', 'sort_column=post_date&sort_order=desc');
if (!empty($nextPage) || !empty($prevPage)) {
echo '
<ul id="nextPrevPages">';
if (!empty($nextPage)) echo '
<li class="next">'.$nextPage.'</li>
';
if (!empty($prevPage)) echo '
<li class="previous">'.$prevPage.'</li>
';
echo '</ul>
';
}
?>
Just added 2 shortcodes to help users that aren’t able to edit their theme files. The two shortcodes are [ next_page ] and [ previous_page ]. Each supports 3 attributes: anchor, loop and getPagesQuery. Each attribute should function the same as the function documentation above.
Let us know if this plugin works for you or you have any ideas for improving it.
Special thanks to Sarah & Frodo for help with testing.
Pingback Next Page, Not Next Post – WP Plugin Archive
How about following menuorder?
Thanks for the suggestion, I’ll update the plugin later today.
Excellent plug-in. I’ve been searching for this for quite some time!!
Works out of the box and I already implemented it in my website to present the categories as chapters in a book. However, when I reach the end of a category (the last page) I want the next page to be the first page of the next category (parent or group) and keep going. Previous would do the opposite. Currently, the plug-in loop through the same group. Is it possible to have the plug-in move to the next parent?
Here is an implementation of the plug-in:
http://www.marcilan.com/pathology/cysts/lateral-periodontal-cyst/
and second question, how do I integrate « to show up only before the title in the previous page and integrate » to show up only after the title of next page?
Thanks!
Wisam, we’re happy you like our plugin.
“Is it possible to have the plug-in move to the next parent?”
This goes well outside the intended functionality of this plugin. It wouldn’t be extremely difficult to make this happen though. Shoot me an email and we can discuss this, mcinvale@binarym.com.
“how do I integrate « to show up only before the title in the previous page and integrate sta to show up only after the title of next page?”
I don’t understand exactly what you’re asking here? Can you give me more detail(s)?
Thanks! Works great.
Now it is working like a charm. Thanks mcinvale for your help. I really appreciate it!!
Thanks for this plugin. I would like to ask how could I disable looping? Although it was indicated that by default it does not make looping it seems that it is working.
The structure is:
A
-B
–C
–D
–E
–F
-G
–H
–I
–J
I use your plugin to navigate between C,D,E,F & H,I,J.
When I am at “C”, I still have the link to “F” as previous page. Idem, when I am at “F”, “C” appears as the next page.
Thanks,
Best regards,
Leave the loop parameter blank or set to false and it shouldn’t do that.
I have the exact same problem as mentioned above. It seems that it keeps looping, even when I leave the loop parameter blank or set it to false.
What could be a solution to this?
I found the problem. The looping only happends with your 2nd example code. The 1st example code example works fine!
Thanks for the great plugin.
It does not seem to honor the false set in no looping.. even though I have set it. The idea I need it for is that the link doesn’t display if there is not a next/previous item.
can you post a link to the pages that you’re using this on? i’m not aware of any bug that would cause this to not function correctly.
It is currently a password protected page.
i can’t debug what i can’t see
I had this problem with the second script still showing the next/previous links when the parameter was set to false.
To fix it I downloaded the latest version and replaced the code in the plugin (1.6 from the paste bin – 3 August)
Then I used:
I then wrapped those divs in an outer div
And floated the div#prev-link left and the div#next-link right.
Hope it helps somebody.
Plug-in works a treat in WP3.0.1
sorry it seems the code was stripped from my previous message:
Darn it.
Here is a link
http://pastebin.com/7pzEhdAN
You have no idea how long I was searching for a way to make my pages (not posts) show the previous – next!
Your plug-in does it perfectly, and I can even sort it the way I want to! Thank you so much! It works on the website for the San Diego Ballet http://www.sandiegoballet.org now, if anybody is interested to see it working, go to the about/dancers/company dancers/individual dancers pages, you can nicely jump from one dancer to the next now thanks to this great plug-in.
Thanks again, I really appreciate it!
Just fantastic – thanks for this excellent plugin.
Very cool! I’ve been bashing my head trying to solve this for the last couple of hours. Then I found your plugin. I should have Googled first, would have saved me a lot of time.
Many thanks for the plugin, it’s working great for me.
Great plugin – works perfect as intended. One quetsions though – I would like to have the title attribute implemented also. So besides the anchor text it also shows the title attribute. Like:
next page anchor text
How would you implement this?
Thanks
What specifically would you like to populate the title attribute?
Maybe just the anchor text at first – so it appears in the title attribute also
Grate plugin thanks!
One tiny but crucial flaw. When viewing single image from attachment template the next and previous Page links point to that same attachment page. When clicked, nothing happens.
Would be so great if you could fix that
Really nice work, thanks a lot!!
The plugin isn’t designed to work with images, sorry.
I’m try to be more clear.
I have five pages that have 10 attachments attached to each. When I’m viewing a page and click an image thumbnail open so that it opens as an attachment page I cant anymore change the page.
I mean I’m still changing from page to page, not from attachment to attachment. I use something like next_image_link() to flip through the attachments.
Hope I explained myself clear enough
I understand what you’re saying, the plugin isn’t setup to do that.
I’d like to change the color of the text. Where do I do that?
You’ll want to use CSS for that.
Thank you. Yes, I am aware of that. Where is the CSS for the plugin?
there is no CSS bundled with the plugin, just add it to your theme’s styles.
I will be extremely grateful if you can help me out with a line or two of code to do that
Hello there… I’m working with the theme IMPREZZ, and so far have not had any trouble editing it. However, when I try to add this plug-in or even others so that I can view previous/next pages, nothing shows up once the code is updated, even if I manually add in the code instead of just installing the plug-in. Is this a problem with the plug-in or is something not communicating right with the theme?
You need to include the functions in you theme’s files for this to work.
Turned out it was an error made by the developer, but he released an updated version of it. Thanks anyway!
Can you tell me which files to put the code in? I’m using Thesis 1.7. Thanks so much!!!!!!
I put it in my custom_functions.php file, but it doesn’t show up. Please help. What am I doing wrong? Thanks!
Cindy, you just install the plugin and then modify your theme files.
Does anyone know Thesis? I guess I’m supposed to put the code for this plugin in my theme’s page.php file, but Thesis doesn’t have that file. It uses hooks in the custom_functions.php file. Any ideas?
Thanks!
Okay, I got it this far. Here is the hook I used in Thesis:
function page_ads() {
if (is_page()) { ?>
|
<?php }
}
Yay. Now, how do I make it so it just does all the child pages and skips over the parent pages? I have the parent page menu linked to #, so it doesn't go anywhere. That's why I need to skip over the parent pages.
Sorry, the code didn’t post correctly in my last post.
EXCELLENT PLUGIN!!!! I LOVE YOU!!!!
This is just what I needed.
Now I am wondering, is there a way to keep looping on, but restrict it from climbing back up in hierarchy, i.e. to get it to go from A in the list below through A1, A2, A3 then to B1, B2, B3 without hitting B?
A
1.
2.
3.
B
1.
2.
3.
You would need to modify the plugin to do that.
This is what I want to do, also. How exactly would we modify the plugin to do that?
Thanks for your help!
Great plugin, it’s exactly doing what I want.
However, when the plugin is used on a page without child pages it will display links to other pages.
Is there a way to dsplay nothing if there are no childpages?
Thanks!
I’d have to see your page hierarchy to understand what you’re trying to accomplish.
What I mean: I have several pages. One of the contains child pages.
When I activate the plugin, and view a chid page verything is OK. When I view a page which isn’t a child page and don’t have child pages it will display a link to the next page.
I kind of solved it right now, to put a IF statement in my template design; if the parent of the current is ID x then show next/prev links.
I have temporarily disabled that IF statement, so you can see on my site what I mean.
All the links on the menu on the top of the site are pages (except the first 2 from the left). Only the link/page called ‘attracties’ has child pages.
You can also see that the ‘about’ page is linking to the first child of the ‘attracties’ page.
if you can email me a link to your site i’ll take a look at it.
I can’t figure out how to get this to work (my fault…major novice here). I installed this plug in, and typed in the above code, but I must be doing something wrong. Could you please tell me exactly the code I should use so that I have “next” “previous” navigation on all the child pages under the FAQs pages of the site? I assume the code should go on each “child” page, and what, if any, specific to my site code would need to be included? Thanks!
Did you get this working? I see the next/previous links on the site you linked to.
Love the plug-in, but I just can’t figure out how to align the text.
I want’Previous’ to be on the left of the page, and ‘Next’ to be on the right.
Any tips?
Wrap the output in a container that floats left and/or right depending on your needs.
Hey great plugin,
I’ve been trying to come up with a solution which you did already with this plugin. Thanks.
My only problem is, I’m using “expand” argument to navigate parent sibling pages, but when I’m on a subpage, it shows it own parent link as next link, not next parent.
I’ll try to explain below:
Parent A
– Sub A1
– Sub A2
– Sub A3
Parent B
– Sub B1
– Sub B2
– Sub B3
When I’m on the Sub A3 page, the “next link” is supposed to show Parent B, right? But in my situation “next link” shows Parent A. I need “Parent B” to show as next link when I’m on Sub A3 page.
I’m using
$nextPage = next_page_not_post(”, ‘expand’, ‘sort_column=menu_order&sort_order=desc’);
$prevPage = previous_page_not_post(”, ‘expand’, ‘sort_column=menu_order&sort_order=desc’);
as function arguments. Also each page have order numbers.
Any ideas would be greatly appreciated. Thanks.
Are you using the same sort_order in your navigation? It looks like your pages are ascending but you’re using descending in the arguments.
I only want to navigate between the parent pages. Is there any way to modify this plugin so that it will exclude child pages?
Never mind I figured it out. If you want the code it’s here:
http://pastie.org/901280
Just modify the “get_pages” function in the plug-in PHP file so that it only grabs parent pages.
Great plugin. I was playing about with it and have added additional functionality for $before and $after to allow text to be included in the tag just like the native WordPress version.
I have put it in Pastebin located here.
Now you can call next_page_not_post($before,$after) and the whole thing is a link.
I haven’t done extensive testing but it works for me
Just fixed a problem with $before and $after still showing when there is no title displayed (ie it has reached the end of the child pages).
Update: Please use this version
Thanks Craig, I’ll take a look at this and possibly merge into the plugin.
Hey great, that works for me perfectly! Just what I was looking for! Thanks!
I’m on WP 3.0.1 btw.
Woops! The before and after text weren’t appearing properly for the next_page_not_post as they were for the previous_page.. but after simply copying the code from the insde of previous_page to _next_page, it works fine now..
Sorry, I don’t know how better to explain..
Ok, I lied previously. It DIDN’T work, but I have fixed the plguin so that it now does work as it should. The problem was that the $before text was not showing up for some reason with next_page_not_post. I have put an updated version here: http://pastebin.com/E94Ekgui
I highlighted the little changes I made.
And I’m an even bigger lier. It still wasn’t working, but now it does for sure.
http://pastebin.com/2kvsqrfD
I got the “next_page_not_post();” link working but not the “previous_page_not_post();”. Is there any way to make it so that the links only show the parent link even if you are on a child page? So for instance: If my site looks like this:
1
2 -A -B -C
3
(Numbers are parents, letters are children)
If a user is on the -B child page then the navigation would be “3″ and “1″ (or vice-versa).
Using this code: http://pastie.org/901280 I was able to make the “next_page_not_post();” link do this, but the “previous_page_not_post();” show the wrong link.
Awesome plugin. It does something that WordPress should do ‘out of the box’. Thanks!!!!!!!!!!
Thanks for this great plugin. It’s working well, however it seems to skip sibling pages which have too high of an order assigned to them. As far as I know, page order assignments don’t need to be sequential (ie- you can have pages set to 1, 2, 5, 10, etc).
I’m using the code which Offminded posted:
$nextPage = next_page_not_post(”, ‘expand’, ’sort_column=menu_order&sort_order=desc’);
$prevPage = previous_page_not_post(”, ‘expand’, ’sort_column=menu_order&sort_order=desc’);
Any ideas?
Thanks,
Jrack
can you email me a link to this in action? it shouldn’t be doing that.
Ok, I’m starting to feel really dumb here, but I can’t seem to get it to work properly.
The first code example displays nothing at all for me, and using the second code example (and variations thereof), the Next Page and Previous Page links just link to the page you are currently on.
I’m obviously doing something wrong, but I can’t figure out what it is. :/
I’m using:
$nextPage = next_page_not_post(‘Next Page’, ‘true’, ‘sort_column=menu_order’);
$prevPage = previous_page_not_post(‘Previous Page’, ‘true’, ‘sort_column=menu_order’);
Example: http://www.varlabs.ca/shop/t-shirts/my-little-betta
The previous/next pages should be the different product pages, but it just links to the same page. The same effect happens on the parent pages as well.
What are you using for your shopping cart? Is each product assigned as it’s own page in WordPress?
Nice betta shirt.
Thanks for all your help, Matt!
To anyone with a similar problem: turns out that the plugin “Exclude Pages from Navigation” doesn’t play nicely with Next Page, Not Next Post. I’ll post an update if anything changes.
Thanks for the plug in! It *almost* does what I need it to, but not quite. I’m doing next and previous pages within sub-pages, which have parent categories. Currently, it only stays within the one parent. I’m hoping to have it skip over to the sub-pages in the next parent, rather than looping within one parent. I ordered all of the pages involved in the WP back end, but it doesn’t make a difference. Any thoughts? Thank you so much!
can you post an example hierarchy or a link to the site you’re working on?
This is one of the completed pages:
http://www.oldfarmslandscaping.com/masonry/terraces-walls/
“Terraces & Walls” is a sub-page of the page “Masonry”. The next/previous buttons will move among pages under Masonry, but will not continue over to the other categories. For example, if you are on the “Columns” page, I would like it to jump over to the “Water Features” page under the “Unique Elements” category next. Instead, it loops back to the “Walkways & Patios” page under “Masonry”. The client is hoping to walk their viewers through each service they provide using the next buttons, under all of the categories listed in the above drop-downs.
Hope that made sense! Thank you so much for your help.
set the 2nd parameter in the plugin to “expand” and the plugin will link the last child to the next parent page.
take a look at the san diego wedding photographer site we did for an example of how this will work.
Hello, thanks for the great plug-in! It is working perfectly just as I need it, except the the order in which the pages are sorted are not congruent with the actual order of my sidebar. I am using the pages widget, and my pages are sorted by Page order, which I control through numbering each post. What function do I use so that this plug in follows page order? I am sure this is a very simple fix, and I appreciate any help in advance.
Again thanks for the great work!
Ryan
Oh well that was easy, menu order works well for this. I had a syntax error regarding a different type of quotes.
Thanks again!
Ryan
Hello! This plugin seems to be almost perfect. Is there any way to modify the code so that it only appears on child pages, not parents. Any help you can give would be great.
thanks,
Euan
Aha! Nevermind I found some help on wordpress dot com to let me add in subpage detection to the functions php.
Thanks again for this great plugin!
Love the plug-in as well. how would I style this though… let me give an example.
I want an arrow left to be the previous and an arrow right to be the next. these two arrows are images. where do i incorporate this into my code to have the image be the ?
thank!
heres a link: http://belovedadvertising.com/mario/successful/urban-sunshine/
Aaron, you should be able to use an image tag with the plugin. I haven’t tested that though. Alternatively, look up CSS techniques for replacing text with an image, there are many tutorials for that online.
Your site looks good.
This is very useful plugin but I am not success on my site. please, give me solution where I put the code. Tell me page name.
Brilliant! Worked straight out of the box
Thanks,
Michael.
Anyway to exclude a page ID? This plug in is a life saver btw!
everything in the final option is passed into the plugin, so you should be able to do something like “exclude=1,2,3,4″
Quick reply! What do you mean by “in the final option”?
Like so:
next_page_not_post(‘Next Page’, ‘true’, ‘sort_column=post_date&sort_order=desc&exclude=1,2,3,4′);
Thanks so much for the help! I am having trouble translating the code to mine
next_page_not_post(‘Next’, ‘true’,
‘sort_column=menu_order’);
I tried different ways of inputing exclude to no avail. Any more hand holding is much appreciated
)
next_page_not_post(‘Next’, ‘true’, ‘sort_column=menu_order&exclude=1,2,3′);
Replace 1,2,3 with a comma delimited list of page IDs you want to exclude.
Hello, thanks for making this plugin! It is almost working perfectly for me… I’m working on a portfolio site with both parent pages and child pages. I do not want the plugin to ‘expand’ and that option is not turned on, however it is still expanding from parent to child in ways that I don’t want. It works properly on the child pages, but not on all of the parent pages. It works on this page: http://scottwolniak.com/sculpture/, but not on any other page, like this one: http://scottwolniak.com/painting-and-drawing/. I’m pulling my hair out… please help. Thanks again!
can you post the code you’re using in your template file?
I have the following in my page.php file:
|
whoops sorry…
|
apparently, i’m a bit dense. i don’t know how to get the code to show up. i’m taking out the ” one last try:
?php echo previous_page_not_post(); ? | ?php echo next_page_not_post(); ?
That should work… do you mind sending me a login to your site? I can try to debug it there.
Unfortunately, it’s not working on my site. I want to connect pages (/blog/001, /blog/002, and blog/003) with previous/next links, but currently prev/next links point to the page I’m on (e.g. when I’m on /blog/002, both prev and next links point to blog/002).
Notes:
1. I’m using the same code as your 2nd sample (01.-19. one) shown above.
2. I’m using “pages” for my blog entries (as “posts” are used for photography part).
2. I use “Custom Permalinks” plugin which enables me to name a URL freely.
Hope these info helps. Thank you for your support.
that should be working… can you send me a login to your site to review it?
Pingback מדריך וורדפרס: פוסטים או עמודים? מה ההבדל ביניהם | felix007.com
I placed the following code into 1l1r-sidebar.php:
1. I would like the little back and forward arrows along with the title (just my title is appearing–not Previous and Next).
2. I would like to include the child pages.
3. I used the Exclude Pages feature for pages I didn’t want, such as non-discrimination and privacy policies. I hope I did that correctly.
4. What if I just want to use this plug-in for one parent (SOAR/POS Tutorial) and its children? How would I do that?
I am a beginner, so I will need step-by-step directions and code examples, please! I don’t understand php and the jargon.
Thank you to anyone who can help me!
Sorry, is there a secret to entering code here? It didn’t show up. Removing ” and ‘?
Let’s try again.
So, how do I place code here? Help!
Another one here who doesn´t know how to get both the arrows and the page title on the link, still can´t figure out the code for both displaying together, as i am seeing it in so many blogs.
I sent you an email but now i think other beginners like me may benefit of this typical and probably silly question.
Nice plugin anyway, i am quite new on this too and i am just learning as much as i can, but this one was already so necesary for wp.
Thank you!!
I tried earlier to get code to show up in a post, and it didn’t work. So I hope this does. Here is what we did to get the arrows. We added &rarr for the right arrow and &larr for the left (see below). These are not the double arrows, which I would prefer, but they work.
// determine if we have a link and assign some anchor text
if ($output) {
if ($anchor == '') {
$output .= $anchorName . ' →';
} else {
$output .= $anchor;
}
$output .= '</a>';
}
return $output;
}
// determine if we have a link and assign some anchor text
if ($output) {
if ($anchor == '') {
$output .= '← ' . $anchorName;
} else {
$output .= $anchor;
}
$output .= '</a>';
}
return $output;
}
?>
To fix the loop issue, change:
isset($loop)
to:
isset($loop) && $loop == true
That shouldn’t be necessary but if it works for you, stick with it.
Great plugin, thanks! I’m just blown away that this is available, since some visitors to my site seem to have problems recognizing or using a menu!
I’d put in a vote for a “before” and “after” parameter, so that I could have something like “Next: Page Title »”
That is on my list of things to add this year.
I need a little help. I have the next_page_not_post parameters set to ‘Next page »’,'expand’,” at present. The “next page” link seems to take me randomly through the menu, so that sometimes I’m jumping forward one page, and other times I’m jumping backward a few pages.
If I have a menu like this:
parent1
-child1
-child2
-child3
parent2
-child1
-child2
-child3
what parameters do I need to set to work through these pages from top to bottom?
Ah, OK! sort_column=menu_order&sort_order=desc seems to have taken care of it.
I have the plug-in installed and i placed the provided code (above) in my page.php file. The links are working, but they loop through. Example: Page A has sub pages 1, 2, 3. page 1 links forward to 2 AND backward to 3, page 3 links forward to 1 and backward to 2, etc. it’s a never ending click-through. How can i break the circle so no previous link appears on page 1 and no next link on page 3?
Set the 2nd paramter to false.
next_page_not_next_post(‘Anchor’, false, ‘query’);
Thank you for the reply. It is currently set to false, I have also left it blank with no success. The links appear and work great (thank you greatly for the plugin) but I cannot get the endless loop to stop. This is what I have:
$nextPage = next_page_not_post(‘Next »’, false, ‘sort_column=menu_order&sort_order=desc’);
$prevPage = previous_page_not_post(‘« Previous’, false, ‘sort_column=menu_order&sort_order=desc’);
adn teh links still continuously loop. page one should only have a next link and page 3 should only have a previous link.
Ok so i found a work-around, thanks for the offer to help tho.
I think there may be a bug in the plug-in. I uninstalled and reinstalled the plug-in and placed the minimum code in my page.php file:
This resolved the looping of next/previous link. BUT whenever i set any parameters, the looping happened again, previous link on pg 1, next on pg 3.
To resolve, i edited the plug-in php file, setting the anchor text here, replacing the default of page title.
Not sure if this is a bug or what, but may be worth looking into.
Thanks so much for the plug-in as well as responsive answers to help. I was able to add if statements to my page.php file as well to limit the links to specific pages as well as add a ‘||’ separator when both previous and next links appear.
Thank you!
This plugin looks good, but I am looking for specific features and I cannot tell if they are present from the description provided. The key feature is the automatic generation of anchor text. I would like the anchor text to support a format string like “← %slug%”, which would substitute the sibling/targert page’s slug into the format and then use it as the anchor.
Another feature I am seeking is the automatic generation of link titles. I would like the title to be either a format string that supported a %title% variable or to default to the title of the sibling/target page.
PLease let me know whether this is possible.
Not part of the plugin currently, I will be adding that functionality though. We’ve been very busy with client work recently, so this type of thing is on the backburner.
hi there, it’s a really great great plugin. I put it in a loop to the page.php code which looks like this:
What do I need to type in and where to hide the next/prev links from parent pages, and to make the links only go between child pages, ignoring the parents? Please take a look here: http://www.parampara.pl/imp/zbiory-parampara/reszta-swiata/
it’s a main page (parent) for ‘the rest of the world’ items, from which you can go to each item’s own page (child). The link at the bottom directs to the last item (child) from india (another parent). I would like it to be gone completely or to direct to india main page, i.e. to previous parent page instead of its child. I hope it’s clear enough
thanks for help
kat
the code went missing, sorry
Greta plugin, well done.
A suggestion would be to respect menu order (as mentioned above) and to allow for having no text in the link (so we can use a next arrow graphic for example). This can already be done by putting a space as the parameter, but its a little hacky.
Otherwise this is great!
Use the third option to control the get_pages parameters, set that to whatever sorting you’re using.
hi there,
is there any chance you could tell me, how can I make this plugin (which is really great overall) respect menu order in a way that if you are on parent page it doesn’t link to next/previous parent’s children, and instead it would link to next/previous parent thus ignoring children? If you’re on child page, can you somehow ignore parents?
What do you have looping set as?
hi
I’m not sure I understand what you mean. The code is in no loop. It’s just on page template, after a post section, and is quite basic without any amendments:
d i v clas= ” navigation ”
d i v clas= ” alignleft ” php echo previous_page_not_post (); / div
d i v class= ” alignright” php echo next_page_not_post (); / div
d i v style=” clear :both /div
That is likely the problem.
How are your pages sorted? Pass the same parameters to the function as the third parameter.
Thanks – but sorry I really don’t understand, what do you mean exactly?
The plugin accepts 3 parameters. Use the third to control how pages are sorted.
thanks, I will do it. Could you please help me out how? I just add “$loop” between the brackets?
I’m sorry, I can’t provide that much support for a free plugin. You should probably try to hire a developer to help you out.
I want to have the next/previous like this. If B is active it should show TEAM and another site on the parent level. Do you have any idea for this. Thanks!
The plugin supports that, read the documentation.
I don’t see it in the docu. Must I change get_pages?
It does’nt exclude child_pages for my site.
I am using something like:
<?php query_posts('post_type=page&posts_per_page=3&post_parent='.$parent);
Which displays 3 posts on a sort of archive page. I know this would usually be done with posts but is it possible for this plugin to display the next/prev 3 page excerpts rather than jump to the the next/prev sibbling page?
The plugin isn’t designed to do that.
i used the way of justin, but it is not resolved at all.
$getPages = get_pages(array(‘parent’ => 0,’sort_column’ => ‘menu_order, post_title’));
If you want to turn off looping set the second parameter to NULL.
This will work (looping is off)
next_page_not_post(‘back’, NULL, ‘sort_column=menu_order&sort_order=desc’);
Setting it to ‘false’ or false will not work.
These DO NOT WORK (looping stays)
next_page_not_post(‘back’, ‘false’, ‘sort_column=menu_order&sort_order=desc’);
next_page_not_post(‘back’, false, ‘sort_column=menu_order&sort_order=desc’);
You’re the looping fix hero for posting this Wayne!
Please forgive my ignorance, I am very new to plug ins. I inserted the short code [next_page] into my page and was directed to the next parent page rather than to the child page. I have attempted to make sense of the codes and comments above but failed miserably:(
that should roll back to all defaults. can you send me a link to the page you’re testing on? i’ll take a look at it.
Really nice Plugin for this missing feature!
Maybe you could add rel attributes “next”, “prev” and “up” for the sake of accesibility
good suggestion, thanks. i’ll see what i can do about including that in the next version.
Yep, what Stefan said. It would solve a lot of people’s problems. Then again, thank you for getting it this far.
I can’t believe this is not in WP core, while it is advertised as CMS, while post categories starting with %category mess things up, so you will have to use pages.
/rant
Hey Matt,
Quick question, is there a way to get this to allow you to loop through siblings and cousins, but not parent pages?
For example:
- A
- – a1
- – a2
- B
- – b1
- – b2
I want to get a1, a2, b1, b2 but not A or B.
Is that possible?
Thanks for the help!
-Drew
You want it to jump from a2 to b1?
Hey Matt,
Yeah, I want to go from a2 to b1, skipping B.
The idea is to go through all grand children, not parents.
Thanks for the help!
You’d need to add some conditional logic to your theme’s template files. Just have it check the current depth before using the plugin’s functions.
Hey Matt,
Thanks, that is a good idea. But I’m not sure what the logic in that test would be?
if( on last child page) {
Jump to first child of next parent
} else {
Go to next sibling
}
And then do similar for previous pages.
I don’t think WordPress has conditional logic to do that sort of thing, that’s why I was hoping this plugin would be able to do it.
Thanks again!
You’re actually correct, it isn’t as simple as I had made it sound. You would need to modify the functions within my plugin to do something like this. Perhaps adding a new check for number of ancestors and continue looping through data if those don’t match.
Hey Matt,
SO I’ve been trying to figure this out. I have a post on stack overflow here:
http://wordpress.stackexchange.com/questions/16875/get-next-previous-cousin-page
I’ve been toying with adding a new “elseif ($loop == ‘cousins’)” statement to your plugin. But maybe it’s easier to just add an if inside the “$loop == ‘expand’” statement that says “if next is parent, then skip, and show the child”.
Do you have any thoughts on that?
Thanks again for the great plugin! It really seems like “next page” should be built into core.
Hi Drew did you ever arrive at a solution for this? I’m developing a site right now that needs the exact same functionality that you describe.
Would love to hear what you finally did.
I added this functionality to the plugin, just haven’t had a chance to update the repository yet. It’s on my to do list, but client work comes first.
Hi Matt,
I’m completely clueless here – I just don’t understand the installation instructions.
Thanks
Mark
What don’t you understand?
I don’t know what the following means:
You say it’s as simple as echo’ing the functions in your page:
That’s double dutch to me, mate.
Also, you say that shortcodes are for users that aren’t able to edit their theme files. It then goes on to say what the shortcodes are, but I can’t see how to actually apply them.
You should probably go the shortcode route, they are:
[next_page]
[previous_page]
How do I apply them ?
I’ve finally figured out how to apply the shortcodes. It wasn’t obvious to me because I’m new to WordPress, & I’m not a technical person.
In the Shortcodes section above it says:
Each supports 3 attributes: anchor, loop and getPagesQuery
How do you go about using these options ?
You should read up on the WordPress Shortcode API here: http://codex.wordpress.org/Shortcode_API
Your shortcode will look something like this:
[next_page anchor="My Anchor" loop="true"]
I’ve got 2 sorted out:
anchor=”x” where x is any text you want
loop=”x” where x is either tue or false
What is the correct format etc for the Get Pages attribute ?
I’ve tried different possibilities, with no luck.
I read through the page you linked, but I’m still struggling.
That goes beyond the level of support I can provide for this plugin. You may want to ask in the WordPress.org forums.
I presume the format would be something like this:
attribute=”x”
Can’t you tell me the name of the attribute & the options for x ?
hey matt,
great plugin works well for child and grandchild pages
i am using the in my template.
how is it possible to use an image for the link and not the name of the page?
best regards
i just found this out for myself:
echo next_page_not_post(”);
cool!
echo next_page_not_post(‘[img src="http://www.ihreleitseite.de/wp-content/uploads/arrow.png"]‘);
That should do it.
Not working with my hebrew site + (/%category%/%postname%/) in hebrew
Can you post a URL for me to review? Language shouldn’t matter.
i gives my just the next page and not the next post..
http://www.zorem.net/%D7%A1%D7%93%D7%A8%D7%95%D7%AA-%D7%9E%D7%A6%D7%97%D7%99%D7%A7%D7%95%D7%AA-%D7%9C%D7%A6%D7%A4%D7%99%D7%99%D7%94-%D7%99%D7%A9%D7%99%D7%A8%D7%94/wipeout-%D7%99%D7%A9%D7%A8%D7%90%D7%9C-%E2%80%93-%D7%A2%D7%95%D7%A0%D7%94-1-%D7%A4%D7%A8%D7%A7-2/
“סדרות מצחיקות לצפייה ישירה” is a page..
it gives me just the next page and not the next post..**
The plugin works with pages NOT posts. That is the whole idea behind it.
oh huh.. srry i haven’t read it before download.
can you help me to find one for posts?
NVM! thanks for all, I got it
im having trouble with this plugin. can someone please help me? i have a lot of Top 10 List on my site and want my readers to navigate through the list instead of it just being one long page. Can you help me with this?
Create a page for each top 10 list and then use the plugin to create next & previous navigation.
ok. but how. with which code?
what are these colorful patterns that each of you have as your icon images??
That is a default Gravatar.
Is it possible to target just a parent of pages and its child?
I use page.php for all pages, with this plugin, all pages show the links. Suppose “Team” page in your example above is a parent page, I want A, B, C, D, E, F and so on to have the previous and next links, but I don’t want the Team page and other Parent pages have the links.
Thanks!
Yep, take a look at conditional tags and/or get_post_ancestors.
Don’t you think a simple example of how the three attributes are to be used with a shortcode would have been helpful?
Nope, I think my documentation explains things pretty clearly. If you’re having trouble with something, let me know and I’ll see if I can help.
Hi, Thanks for this nice plugin.
I seem to have some trouble with the $loop.
It loops, although I’ve tried both ‘false’ and putting nothing in it at all… as it should default to not looping… any ideas?
This is how I use it:
<?php
$nextPage = next_page_not_post('%title', 'sort_column=menu_order&sort_order=asc');
$prevPage = previous_page_not_post('%title', 'sort_column=menu_order&sort_order=asc');
$nextPageTagged = str_replace('" title=','#access" title=',$nextPage);
$prevPageTagged = str_replace('" title=','#access" title=',$prevPage);
if (!empty($nextPage) || !empty($prevPage)) {
if (!empty($prevPage))
echo '
<<< Ga terug naar '.$prevPageTagged.'
';
if (!empty($nextPage)) echo '
Ga verder naar '.$nextPageTagged.' >>>
';
}
?>
Try this:
next_page_not_post(‘%title’, NULL, ‘sort_column=menu_order&sort_order=asc’);
Yes, thank you! That works!
Hi there,
how can i exclude the function on certain pages? For example: i don’t want to display the links on the home page or the contact page. How can I manage this?
By the way, i love the plugin. Didn’t expect something like this exists, it’s really helpful.
Wrap the function with a conditional statement, something like this:
// exclude from the frontpage
if (!is_front_page()) {
// include your next-page code here
echo next_page_not_next_post();
}
Check the Conditional Tags page in the codex: http://codex.wordpress.org/Conditional_Tags
sorry, but i cant see any code
could you please explain it further?
Edited my original comment to include sample code.
This works for me, but the » and « chars are not displayed anymore… why? do you have a solution?
I now solved the problem, thank you very much
this is my code:
Hello –
i’m pretty clueless in PHP so I’m using the short codes. Wondering if you could tell me how (if it is possible) to have the next/previous posts be based off of the order as defined by the menu order.
Thanks.
Also – I use a genisis theme and the menu order is based under the appearance as opposed to the “My page order” under pages. Not sure if that matters.
The plugin follows menu_order by default. I don’t know enough about Genesis to tell you if that is interfering with the plugin.
Is there any way to have the links just say “Previous” and “Next” instead of the next page title?
The first argument with each function is the anchor text, use that. Something like this:
next_page_not_next_post(‘Next Page’);
previous_page_not_next_post(‘Previous Page’);
Thanks for the great plug-in but I have a functionality request.
My hierarchy is:
Parent A
– Child 1
– Child 2
– Child 3
Parent B
– Child 1
– Child 2
– Child 3
I would like this to go from Child 3 > Parent B on “Next”. And the reverse, Parent B > Child 3 on “Back”.
Is there a way to do this?
Set the 2nd parameter of each function to ‘expand’.
Great that works well for going forward “Next” but it does not jump backwards over the Parent.
Example:
You can go from Parent A (Child 3) > Parent B (Child 1)
BUT NOT
Parent B (Child 1) > Parent A (Child 3)
Any ideas?
Thank you for your work, this is an indispensable plugin for wordpress!
Excellent! Invaluable! Finally get those perky links to work! :p
hi there i got it working with images.
and i want to have a hover effect at the image to change its color
?php echo previous_page_not_post(''); ?>
when i tried this there comes an error page.
normally this works quite good with image links. how can i get it working with the plugin?
best regards
thomas
I’m not really sure what you’re asking. if you’re getting an error, debug that. I deleted your other comments.
i do not have skills to debug.
you are the men who wrote this cool plugin and might have the knowlegde to solve my little problem.
Please don’t post multiple comments, I’ll reply to your original message as time permits.
What does the error say that you’re receiving? That is the first step in debugging this.
okay,
i got:
Parse error: syntax error, unexpected T_STRING in /homepages/44/d177360701/htdocs/janinearnold.net/wp-content/themes/agency/page-pics.php on line 27
what i try to achieve is the following:
i am using the plugin for switching sites.
i am not using text links but images.
left and right arrows.
they should change colors when hovering over them. that’s all!
As I previously stated, *please* do not post multiple comments.
If you’d like me to debug your site for you, you’ll have to pay for the time. We currently bill at $125 an hour.
You have a syntax error in your PHP.
are you kidding?
of course i got a syntax error. that’s why i’m asking you! i use a code that is working on many sites i created. somehow i cannot figure out to send it to this forum and you are not even explaining how i can do this.
if you are a plugin creator with honor and willing to give support here, it will cost you 1 minute to find out this little thing.
for 125 usd i can hire somebody that writes me a new plugin. how about 20 bucks though?
all my best
Telling someone they don’t have honor is really bad way to ask for help. You should hire a developer to assist you with whatever you can’t figure out. Have a good Sunday.
Hey this plugin works great! I am having one tiny problem that I’m trying to figure out, and I’m not the greatest with PHP. Right now I have about 5 parent pages and some of them have a couple child pages. If you are on a parent page (that has children of course) the plugin will cycle through the parent pages. If you are on a child, it will just cycle through the children of that parent.
I’m trying to get it so that the plugin will cycle through the parent and just it’s own children. Is this in any way possible? I would really appreciate your help on this one. Right now I have the Previous/Next links hidden on the parent pages.
Todd, can you show me an example of page hierarchy? I think I understand what you’re trying to accomplish, but it’s not perfectly clear.
Thanks.
I can give you a link to the site I’m working on, but wish to not post it here since it isn’t complete. Can you email me (toddmette[AT]gmail[dot]com) and then I can send you the link with further details?
Hello!
great plugin but how can I add » and « before and after page title.
Thanks everyone.
%title gets replaced with your page’s title, so you can do something like this:
next_page_not_post(‘%title »’);
I would like to build a manual and I use parent pages with several child instances.
Now I would like to offer the next page link to the first child of a parent, and so on to the instances.
The parents are menu Items on my page. And to have the look an feel of a manual. I would like to create a loop within one parent page infrastructure.
I use the shortcode variant because I wouldn´t like to integrate the function on all pages. Only for my manual.
This ist a possible structure:
P1
- C1
- C2
- – C2-1
- – C2-2
-C3
-C4
- – C4-1
- – C4-2
… and loop back to Parent.
So I realize closed chapters for my readers. Offering them over menu Items by parent pages.
Is this possible? And when, please forgive someone who is not very firm in php. I need a little more help.
Thanks.
From what I understand, that shouldn’t be a problem. You’ll want to hook into the “the_content” filter and use that to control the output of your functions.
This is the original code:
function next_page_not_post($anchor='',$loop=NULL, $getPagesQuery='sort_column=menu_order&sort_order=asc')What Do I have to change. I tried something with parent and child_of but it seems to be not working
http://codex.wordpress.org/Function_Reference/get_pages
The markup will depend on what level of page you’re currently in. You’ll have to adjust the options based upon what you want to output.
just tried your plugin,it’s awesome
Thanks!
Pingback Wordpress plugins used | WTJR online Bible KJV
I’d like mine to work so that it stays inside the current parent. My pages are set like this…
A
-1
-2
-3
B
-1
-2
-3
If I am on A there is no prev link. If I am on A3 then there is not next link. It keeps me inside the current partent and child.
Possible without modification?
Thanks!
Hi,
I modified the plugin a while back, because the before and after text wasn’t working for me. My version (based on .1.7, not the most recent version) stays within the parent, at least, it does on my site! No guarantees that this’ll work for you, but it works for me. Here’s the code:
http://pastebin.com/QWQDLqWA
Hi Ed, short of forking the plugin, I would use a conditional inside of my template to accomplish this.
Thanks for the plugin. It worked great; just what I needed.
Am I missing something? I cannot for the life of me figure out where to post the following, or if the following is even correct:
functions.php? page.php? template.php?
Thanks
I can’t see your code, but you most likely need to use page.php.
sorry I uninstalled it for the time being.
okay so I am using dynamic templates in my theme so I installed this:
<?php
$nextPage = next_page_not_post('Next Page', 'true', 'sort_column=post_date&sort_order=desc');
$prevPage = previous_page_not_post('Previous Page', 'true', 'sort_column=post_date&sort_order=desc');
if (!empty($nextPage) || !empty($prevPage)) {
echo '
‘;
if (!empty($nextPage)) echo ‘
‘.$nextPage.’
‘;
if (!empty($prevPage)) echo ‘
‘.$prevPage.’
‘;
echo ‘
‘;
}
?>
in my template-dynamic.php because your shorter code didn’t seem to do anything.
but look, its in the bottom right corner of the page:
http://revamp.metropolitandetail.com/?page_id=818
I would like it in the bottom of the page content. And I don’t see the arrows!
okay I got it to work but now I want the PREVIOUS to be on the left and the NEXT be on the right but I’m not sure how to do this
Wrap it with a container element and float it.
I am a newbie so I’m not sure how to do this. Can you point me in the right direction how to code this and where to put this?
Also, how do I exclude certain pages? If you go here:
http://revamp.metropolitandetail.com/
I only want ALL the service pages to have this feature. so you should be able to scroll from DETAIL (and it’s child parents) all the way to BEYOND (down to the last child page called leather conditioner
)
and then I wish for it to stop. So in theory there would be a <> and similarly starting at SERVICE would only provide a NEXT >> link and no PREVIOUS <<
thanks
Read up on CSS & WordPress conditional statements.
Hi.
I have the following:
A
A-1
A-2
A-3
B
B-1
B-2
…
I want to go this way: A->A1->A2->A3 STOP!
How?
Hello,
Can anyone tell me in which template i put the code???
I use photocrati theme.
Thanks
René
Great plugin! One quick question… I noticed a user commented a few years ago asking about using this plugin with the “Page Title’s” being printed instead of “Next Page” and “Previous Page”. I didn’t see a resolution to that here.
Is this possible? Can you simply call the page title in the PHP?
Anyway, just curious if this is possible. The plugin works great even without this function, thanks!
Leave the first parameter blank, or use %title