on December 7th, 2004Previous ‘n’ Posts
Updated version 2.0, for WP 2.1. Download it !
On a Permanent Link page, I wanted to display the previous 5 posts.
I searched the WP Community Forum, but couldn’t find one.
Then I got another plugin for Recent Posts , by Nick Momrik and made a copy of that and created a new plugin.
Now I present it to you Previous ‘n’ Posts Plugin.
The Usage is quite simple
<h2>Previous Posts</h2>
<ul>
<?php get_previous_posts(6, ‘<li>’, ‘</li>’, true, $post->post_date,false) ?>
</ul>
Number of posts to be displayed,
‘text to appear before link’,
‘text to appear after link’,
should_show_password_protected_post (true/ false) ?,
date of the current post,
should_show_excerpts_of_the_post (true/false)
Thats it.
Go Ahead and download the Zip file from previous_posts.zip,.
It also includes a ‘readme.txt’ file.
Just save the ‘previous_posts.php’ into your ‘wp-content/plugins’ folder in your WordPress directory and activate it from the Admin Area.
Always use the code from the readme.txt file, and do not copy it from this page.
the code that is shown in this page, is just to let you know how to use it.
Its not the actual code.
Let me know if you have any problems.
Enjoy !


I’m using your Previous ‘n’ Posts plugin but the date of the current post is not showing. Please help.
Hi Beng,
I dont see any problems in your blog. I am already using it in my blogs and I dont seem to get the above mentioned problem.
Did you do something to cause it / correct it ?
Thanks
Hi Sadish,
Oh I think I have formulate my question in a wrong way. Actually, I have seen someone using something like this plugin. The only difference was that along with the list of his previous entries, there was also a post date included before the title of each post. Is ist possible for me to do the same? If yes, how shall I do it and which part of the file?
Btw, many thanks for answering my query and also thank you in advance for the coming reply :)
hi, it’s me again. sorry, i am such a bother…but anyways…i found out how to do it.
greetings from germany!
the plugin doesn’t work for me. I’ve inserted that line into index.php. But when I load my blog i get this line:
Parse error: parse error, unexpected ‘>’ in /home/exileds/public_html/carine/index.php on line 68
I’m confused what should I do?
Please do not copy the lines of code from this page.
Copy it from the readme.txt and use it.
That should solve the problem.
Hi,
Your plugin is good. Is there some way to use it in conjunction with the page-navi plugin? I’d better explain. If I have say 10 posts paged, can the plugin be adapted to show the titles of the 10 previous posts that are not showing on the blog homepage?
Thanks a lot.
- Andy
Andy,
Unfortunately, this plugin will not do the ‘next’ n posts. I understand that you are expecting it to that.
If you need that, I can send you another plugin that does that.
email to reachme @ simpleinside.com
Your plugin does not work in the menu for 1.2.2.
Perhaps an idea for a new or modified plugin one day after installing your existing ones…
When posts are paged on the homepage and the plugins previous’n'posts and/or next’n'posts are implemented in the menu, when the reader clicks on a title, the blog will show just the post selected. In the “div” containing the text of the selected post, it would be nice to show before the title a list of the previous n posts and after the text, a list of the next n posts.
The advantage is to render the titles of previous and next posts more visible as the menu can be considerably longer than the text of the originally selected post.
I get the same problem as Carrie, and I copied it from the txt file. This character “>” is simply not allowed. Unless it’s in ‘ and ‘.
Ah, it does allow the date part with this character, >
But when I copied it from my txt file, the single-quote marks were slanty. So I replaced them with straight ones. It didn’t recognize those as single-quote marks. Therefore my
gave the error.
Very strange that it does that.
It works brillianlty now. Only a couple of minutes of total site shut-down. Heh heh.
It works on the index AND on the entry pages. Again, brilliant. You should fix the read me file, though. And explain why not to copy from this web page.
Yes…
The Problem is with the single quote character. It gets to a ’slanting’ single quote once u display it on the page.
I dont know why.
So till we figure that out,
1. first copy the code
2. delete the single quote and put it again on the same place.
that will fix the problem.
if any of you know the solution to that, let me know please.
Thanks.
Your download link does not seem to be working for me, I would really like to try this script and see its versatility firsthand :)
If you have a copy of this locally I would be grateful if you could email it to me on the email address specified when I filled out this form :)
Hey John,
I updated the link and you can download it now.
Thanks,
Sadish
Truely awesome, quickest response to almost anything I’ve had in my life lol. I almost forgot about this until you emailed me ! … Been at it for 3 days downloading and finding new plugins for wordpress (only started the program on sunday) and already I’m interesting in creating my own.
Hopefully I’ll be able to find out how to write plugins within a few weeks, I guess php and mysql can’t be that tough huh? :o?
Thanks again for the download link :)
John
Hi. Thanks for making this cool and necessary plugin. I installed it on my site, but for some reason am getting a “no more previous posts” message instead of a list of the posts.
The only thing I modified was to take out the date display. The plugin was activated successfully.
Here’s what I have: “‘,true,”,false) ?>”
thanks for any help.
Nice plugin. Thanks for great job! :)
I’m having the same problem as Alex. I’ve got it installed, but instead of it displaying a list of previous posts, it simply displays “No more previous posts.”
Input appreciated. Thanks.
Hello. I installed the plugin, entered the code in the sidebar, and everything looks fine. However, the “recent” posts listed are the most “recent”, but start from a couple of days ago. How can I make it so that the most recent post in the sidebar is the most recent post that was posted?
http://veritasredux.com
Thanks,
Evan
Even May.
The Idea of my plugin, is to display ‘Previous Posts’, meaning anything that is not displayed on the front page.
if you only want the most recent posts to show up, use this plugin.
http://dev.wp-plugins.org/browser/recent-posts/trunk/
Thanks
Sadish.
ah. thanks
I have clicked on the links of all the commenters and none of them seem to have this up on their sites. Also you don’t seem to have it on your site either. Does this tell me something? Does it still work?
Jen Leheny.
Have you really tried it on your website ? does it not work ? what is your problem ?
Hi Sadish, thanks a million for this plugin!
Had a problem with the slanting single-quote marks, but it works wonderfully now ;p
Many thanks!
Jen Leheny, yes it still works ;p I haven’t checked out the other commentators yet, but you can check it out at my site, http://www.xmercenaries.com/four9er
Cheers!
Oh, and it’s on the single post pages, just in case you don’t see it on the main page and was wondering ;p
Nothing huge, but I changed this a bit to show posts from a particular category:
first 10 or so lines of the function:
function get_previous_posts($no_posts = 5, $before = ”, $after = ”, $show_pass_post = false, $current_post_date=”, $show_excerpts = false, $category_id = false) {
global $wpdb, $tableposts;
if (!$category_id) {
$request = “SELECT ID, post_title, post_excerpt,post_date FROM $tableposts WHERE post_status = ‘publish’ “;
if(!$show_pass_post) $request .= “AND post_password =” “;
$request .= “AND post_date
li tag doesn’t seem to do anything nor does the $post->post_date. Plugin works anyway, thanks :)
Hi Sadish,
Thanks for writing the plug-in. I am using it to display all my previous posts seeing as how I have made the effort to write them. I am still trying to figure out how to make them black.
I used this date function - gmdate(”Y-m-d H:i:s”,time()) -instead of the - $post->post_date - as I was also getting “No more previous posts.”
My website is http://www.argentina2alaska.co.uk if you want to check it out.
Annette
[...] Previous Posts [...]
link to plugin not working
Thanks nick for pointing out.
It is fixed now. Try it now.
Thanks
Sadish
This is probably a really stupid question, but how can I style this to make the posts display horizontally (inline) instead of vertically?
Thanks!
Mackenzie
try defining a unique id, to the <ul> tag that is used when you call this plugin.
say <ul id=”recent-posts”>
and then add this part to the style.css
ul#recent-posts li {
display:inline;
}
[Please understand that this is not a bug with the plugin, and support for this kind of questions is limited ].
Thank you for your reply! I do understand that this isn’t a bug with the plugin, I should have specified that. CSS is a bit new to me and I have been trying to style it in the Stylesheet with no luck. I was hoping there was some formatting in the plugin or something that I was missing :). This didn’t work either but I’ll keep working at it- I’ve been looking for something like this plugin for a long time.
After some work I think I’ve gotten it figured out with a little bit of doctoring of the plugin script. Thank you for your help!
[...] Previous ‘n’ Posts (download) [...]
ur readme file code is not correct,i keep getting syntax error, can you please let me know the exact codes to enter:
Usage :
———
Previous Posts
? ?/li>? true, $post->post_date,false) ?>
above is what i see from ur readme.txt ….. :(
[...] Ahead and download it [...]
copied ur code in my templates it seems doesnt work. but im try it with this code :
Previous Posts
“, “”, true, $post->post_date,false) ?>
and its work.. thanks for the code :)
[...] I found the Previous Posts (recently it was updated to work on WP 2.1) plugin by Sadish Balasubramanian. Still, it can only [...]
[...] Previous Posts [...]