Next Previous Posts in Same Category
I’ve gotten a few emails about my (old) Next/Previous Post in Same Category plugin and about the fact that’s its broken - however, this functionality is now built into wordpress. (and I have it working on the site right now as a matter of fact). I’m a bit behind on what has been included with each new version of Wordpress, so I’m not sure when this made it’s way in there, but.. YAY! Now I don’t have to update the plugin! LOL! So, in any case, if you want to include links to the next/previous post in the same category as the one being viewed, you just need to do this (on the “single.php” template page INSIDE the “Loop“)
<?php previous_post_link('« %link', 'Previous post in category: %title', TRUE); ?>
<?php next_post_link('%link »', 'Next post in category: %title', TRUE); ?>
Where the first argument (where I have “« %link”) is the format of what is displayed… ie. if you want text before or a tag around the actual link (represented by “%link”) this is where you say how you want it to show.
And the second argument (where I have “Previous post in category: %title” is the text of the actual link. You don’t have to have the “%title” in there - but I think it’s useful)
December 4th, 2007 at 1:38 pm
[...] ver 2.3.1). However - it is also no longer needed as this functionality is now part of Wordpress. Please see this post for more details. I will leave this post up here for the sake of archives, etc. but it is no longer [...]
January 17th, 2008 at 5:33 pm
[...] scriptygoddess teach us how to insert Next and Previous post in the category in which you can see at the bottom part of my blog post. [...]
February 7th, 2008 at 9:41 am
Hi Thanks for the heads up
i was wondering if there’s a way to do it for pages too?
thx in advance for the info!!
March 9th, 2008 at 2:46 pm
What if a post is in multiple categories? Which one will it go to and how can you control which one it goes to?
March 9th, 2008 at 9:40 pm
Hmm… good question. AFAIK its just showing next/previous on one category - but how it decides which one (and how to get it to show the others)… not sure..
April 14th, 2008 at 1:55 pm
A long shot … any idea if it can be made to work on category children?
April 20th, 2008 at 1:20 pm
Thanks for posting this. I wouldn’t know it is already in the codex if not for your post. Is there a way to add the post excerpt right below the title? TIA.