WP Plugin: Latest Posts by Category Archive
February 18th, 2009 / Blogging Tools, WordPress Plugins
After posting the Latest Posts by Category Archive tutorial, I’ve received requests to transform the code into a WordPress plugin.
Update: Version 1.2 has been released. Read about the changes below, in the “Version History” section.
The Features of ‘Latest Posts by Category Archive’ WP Plugin
Here’s the list of features currently available:
- Can be used via hard-coding inside page templates;
- Can be used as a widget in your widget-ready areas;
- Can be used via shortcodes inside pages’ or posts’ content;
- Can be used either inside or outside the loop;
- Can limit the archive to certain categories, or exclude certain categories;
- Can display or hide post dates;
- Can display or hide post excerpts and adjust their length in words;
- Can set the number of listed post from 1 to ‘all’.
Version history
Version 1.2
- The plugin is now available as a widget for your blog’s widget ready areas;
- The widget’s output can be easily customized using a few newly added CSS classes. Information about the widget is available in the plugin documentation, which is also included in the download package;
- Fixed the dashboard area that notifies WP 2.7+ users on the latest plugin version available.
Version 1.1
- Added option to display post dates;
- Added dashboard widget for plugin version tracking (Only available for WP 2.7+ users).
Documentation
The plugin documentation is available for download in PDF format: LPBC Documentation (2091)
For further information and plugin updates, please refer to this page, as it will be edited with further improvements.
Live demo
The following list has been generated by the use of the next shortcode within this post’s content:
[lpbc posts="3" categories="1,3,23" more="Archive of %name%"]
Enjoy the plugin!
-
- Spread the love!
- Digg
- StumbleUpon
- Delicious
- Fast & Free RSS updates?
- Join the 1,353 subscribers NOW!
More Blogsessive Content
This article has 90 comments
Add a comment
14 blog posts linking to this article
- Latest Posts by Category Archive with WordPress | Blogging Tips from Blogsessive
- New WP Plugin: Latest Posts by Category Archive
- Latest Posts by Category Plugin v1.1 Update | Blogging Tips from Blogsessive
- Latest Posts by Category v1.2 - Major Update | Blogging Tips from Blogsessive
- WordPress Plugin: Latest Posts by Category v1.2 - Alex Cristache
- I Need Your Translation Skills! | Blogging Tips from Blogsessive
- WordPress Plugin Releases for 04/07 | Weblog Tools Collection
- Blogsessive: Latest Posts By Category Plugin
- nCoded » Blog Archive » Wordpress Latest Posts Plugin
- My Take on the WordPress Themes & the GPL License | Blogging Tips from Blogsessive
- 10 WordPress ‘HOW-TO’ to Give it the Quality it Deserves
- 10 секретов и примочек для wordpress | cooledit
- New Design, New Content – Asnio Back in Full Swing
- Create a Magazine Blog – Displaying Latest Posts by Category WordPress Plugin

Great plugin. It’s perfect for better indexing of new articles.
It has its own pros and cons like “Related articles” plugin, but combination between these two plugins will improve your ranking
Thanks for sharing with us
Is it possible to configure this plugin so it displays the cat archive in a sidebar and correlates with the individual page displayed.
For example, a single post from the cat “Dogs” is displayed and the sidebar would have x number of post titles from the same category.
If a post from the cat “Snakes” were then displayed the sidebar would have a listing of the “Snakes’ archive.
Marc, it is possible and will be implemented in the next plugin update.
Thanks Alex, I look forward to when it’s released.
Thanks for great plugin . . .
Thank you so much!!!
Fatal error: Call to undefined function: strip_shortcodes() in /usr/www/users/africaxxnp/corporate/wp-content/plugins/lpbc-archive/lpbc-archive.php on line 143
Cud u plse offer any advice?
Simon, if I not wrong, you’re using an older WP version, 2.3 or below, and that’s why this happens. The best thing would be to simple upgrade your installation, not only to make this plugin work but mostly because since 2.3 a lot of security issues have been fixed.
If you decide not to upgrade, there’s a small hack you could use, but this only ensure that you don’t get the error, not that you actually strip the short codes.
Open the lpbc-archive.php file and scroll down to the last lines.
Paste this:
if (!function_exists('strip_shortcodes')) { function strip_shortcodes($content) { return $content; } }Before:
add_action('wp_head','lpbc_css');Is there a way to add the date to each of the displayed posts?
Thanks,
Mike
Mike, currently, the only way to add a date is to edit the output in the plugin’s source file. Obviously it’s not recommended since it will be overwritten at the next plugin update.
But, speaking of updates, I’ll consider introducing the option of displaying post dates.
Thanks for such a great plugin! Just what I needed! =)
I’m having one problem though that I hope you can help me with. When I include [lpbc] in my page- it works fine, but when I try something like:
[lpbc posts="5" categories="557" more="Archive of %name%"]
…I get no posts displayed.
Any help would be greatly appreciated. Thanks again! =)
Will, I’ve just tested the plugin with your exact code, only changed the category ID and it displays fine for me.
Are you sure the category ID (557) is correct?
Alex,
Ooops! I’m an idiot. You’re absolutely right- I was using using a non-existent category ID. Thanks for the quick reply and help! =)
Hmmm…sorry to bug you again, Alex- but it’s actually still not working. I’m having the same trouble I did before with 2 different category IDs that I know exist. The code for Cat #557 is still working, but when I enter the following in a new post:
[lpbc posts="10" categories="626,627" more="Archive of %name%"]
…or just one or the other ID, I get nothing. When looking at the page source I get the following:
Strangly enough, when I re-enter (which I know still works on another page):
[lpbc posts="5" categories="557" more="Archive of %name%"] it does not work on the new pages I’m trying to create either.
Appreciate your time and help with this. =)
Will, without a website to check and see ID’s for myself it’s basically impossible to do debugging on something that works fine for me.
Will this work on Blogspot sites too? By the way, thank you for this helpful information.
Alex, after further investigation, it appears that I only have a problem displaying categories with fewer than 1 or 2 posts. Any ideas? Thanks!
Will, I’ll do some more testing and see what results I come up with. I’ll let you know.
i will try it
Great Plugin!
Is there a way to show the top posts per categry?
Best regards from Berlin Germany, Phil
Thanks for the plugin! I am going to try this out on my new Wordpress blog.
Phil v. Sassen, I’m sorry but this plugin is not intended to be a “most popular” posts plugin. It is only a categorized archive of the most recent posts.
Johan Nilsson, you are welcome. Enjoy the plugin!
Alex, any luck in figuring out what the problem might be with displaying categories with fewer than 1 or 2 posts? Appreciate your time and help. =)
Will, I’m really sorry but I cannot figure out what is wrong, if there is anything wrong. I’m questioning this only because I’ve tested the plugin again and again with newly created categories, empty categories, categories with 1 ore to posts, and more posts.
Empty categories are by default not displayed, but categories with 1+ posts are displayed fine.
Sorry, but without local server access I cannot find out specifically what could cause this problem in your case.
Great plugin, thank you. Is it possible for it to show images? I have a photography site and would like to show my separate categories (separate genres) which each post concerns a photo.
Also, is it possible to add a space in between each post?
I’m currently testing things here: http://www.e-lusion.co.uk/portfolio/
Kol Tregaskes, I’m sorry but currently it does not display photos and I don’t plan to include such a feature. Spacing between posts can be set by adjusting the CSS settings as explained in the help files. There are some classes you could use in order to style your archive.
This plugin is exactly what I was looking for. Is there a way to NOT display the category name in the list? Just the recent posts?
Frank, the plugin is meant to do just that, organize the most recent X posts into categories.
Otherwise it would simply be “the latest posts widget” that comes built in with WordPress.
If you plan to achieve that, you should look at the query_posts template tag in the WordPress Codex.
Wow, this looks like a great plugin but I am confused. I did read the docs.
I have a food blog and many blog posts in two different categories: Chicken and Fish.
I want to use this plugin to show the last 5 posts in the Chicken category and then use it again to show the last 5 posts in the Fish category and I want these to show up in the sidebar.
I installed and activated the plugin but I am not sure what to do next. Can I add a text widget and put code in there to make it work? If so, what code what it be?
Thanks so much!
I have used quite a few plugins, but this one is simply fantastic. Not only does it show the category archive according to latest posts, its free too
Hello, is there currently a way to include child categories? I’ve looked through the documentation, sorry if I missed it!
Thanks so much.
I am having trouble displaying separate categories using shortcode. I am using permalinks… when I enter the category number nothing comes up – when I enter the permalink name for the category, all categories are displayed instead of just the one.
[lpbc posts="3" categories="3" excerpts="true" length="20" more="Archive of %name%"]
[lpbc posts="3" categories="Latest News" excerpts="true" length="20" more="Archive of %name%"]
Any help is greatly appreciated…
Rich V
Thanks for sharing this.
Like Amanda, I also would like to know if there’s a way to show child categories’ posts.
Update: To show child categories too, I deleted this statement from the query, near line 105 in lpbc-archive.php:
AND wtaxonomy.parent = 0If you use the widget you’ll have to adjust the according query for the widget too.
Mind you; after an update you would have to repeat this, so it’s not ideal.
Amanda, Tibor has pointed out to a good solution until the next plugin version will be released.
Version 1.3 will include option to display either only top categories, or all categories.
The reason I implemented only the top level categories is to reduce the risk of having duplicate links for posts added to both top and sub categories. It might look like link spam to certain engines. But if you people need it, I can only warn you about it and let you decide whether you use it or not.
Rich Vernetti In the categories attribute you need to enter the IDs of the categories you need displayed. Not names or slugs. Make sure you have a category with the ID=3, and also, make sure it’s a top level category. If it’s the subcategory of another it won’t be displayed. Currently, the plugin only works for top level categories.
Version 1.3 will come out sometime next week and will include translations in a few foreign languages and the top/all level categories switch.
Is there a method for formatting the date in this plugin? I have sifted through the php and cannot get it to display the date other than YYYY-MM-DD, whereas I would like it to display the date in the Wordpress format -> the_time(‘l, F jS, Y’).
Is there a way to change the color, size and font of the text? Would be cool if it was built into the widget.
Thanks in advance!
Russell =)
Thanks for a great plugin.
I’ve come across a problem that I couldn’t solve on my own.
When you publish posts from drafts you’ve written & updated over a lengthy period, it seems that the plugin pulls the date from the 1st draft for its lists. That way the freshly published post doesn’t appear at the top of list for latest posts. The posts show up in right order in category pages & on the front page.
Any ideas how to solve this? Have I missed something?
I’m using the plugin via hard-coding inside page templates.
Hey,
Thanks for the plugin. Is it possible to sort the categories by the order you type them in, rather than the numerical order?
For instance, if I choose category IDs 10,9,8, there are displayed in the order 8,9,10.
Thanks in advance!
Get this error message in the admin/widget area :
Fatal error: Call to undefined function:
strip_shortcodes() in /home/******/public_html/family/wp-content/plugins/lpbc-archive/lpbc-archive.php on line 313
… using WP 2.5
Any ideas?
Is there a way to use this widget more than once. I have a plugin that displays a specific widget on specific pages, and I need different posts lists on different pages.
Do you think that is possible?
Thanks,
Hey Guys!
I need your help.
How can I change the dateform to “d.m.Y”?
Sorry bad engl., but I hope you can understand me…
Greetz
Peter
Peter, with some PHP knowledge you could edit the lpbc-archive.php files to modify the output yourself.
There are two places that need editing. One handles the in-post output, the other handles the widget output. If you search for -> if ($date == true) <- without the arrows you find both entries.
Good luck.
Sorry Alex, but I don’t know what I have to edit and how it goes…
What things I have to add?
Greetz
Peter
Thanks for the word on this plugin, its great!
I am trying to change how it works a bit to display the order by a set Category order, instead of by the latest post ID.
Is that something that is possible? I also use My Category Order for my menus and other places I want My Order to work… Was trying to combine functions from both plugins with no luck.
any advice would be appreciated!
Thanks,
Dale Jacobs
It seems like the sort order is set by the date when the post latest were changed.
Is there a way to get the plugin to sort the posts after published date, instead?
OK.
Now I see!
The sort order is set by PostID, not changed date.
My question still remains:
Is there a way to get the plugin to sort the posts after published date, instead?
Thanks for a great plugin. I’m running WP 2.8. Unforunately, I’ve tried both widget and in template () and nothing appears.
No errors present in error_logs. I have plenty of cats and subcats with posts in all.
Thanks for any help?
man, after my recent wordpress upgrade (version 2.8), this plugin stopped working
:(
wordpress 2.8 sux, most of the themes dont work on it either
:(
I´m using another plugin instead:
List category posts Wordpress Plugin
Says on homepage that it working up to 2.7 but it´s working fin in my 2.8
http://picandocodigo.net/progr.....n-english/
Guys, did you look at the end of the post? Do you see the list of posts extracted there?
Well, Blogsessive is running on 2.8, and so, the plugin runs on 2.8.
Don’t blame the plugin or the WordPress version, most times these things happen due to conflicts with other plugins or themes that are not that well written/coded/updated.
The LPBC plugin does not use version-specific coding, so it’s not affected by the latest WP update.
I have a newswire site with columns for each news category (headlines, fashion, food, events) and would like to use this in my sidebar. however, is it possible to include the gravatar and name of the author in the display along with the post titles? how could i incorporate this into the plugin? thanks
When will be available the multilanguage version?
Great plugin, are there any future to add a sort by Alphabetical category name? Would be a great addition!
Is there a way in the code snipped version to NOT display the category URL? I’d just like a list of the posts alone – the page title is my Category Name.
Thanks!
Of Course! Use it like this:
[catlist ID=9 orderby=title order=asc numberposts=-1]
Displays ALL post in category ID 9, ordered by title (A-Z)
I use that on my site.
Could you explain how exactly you modify the date display to become d/m/y ?
Hey guys,
Is it possible to exclude the most recent post? If yes, how!?
Best Regards
Christoph
Hi! thanks for the great plugin.
I have a problem.
I wanna show only the name of the lastest 7 posts on the category 134.
I only get to show a the category name. Can you helpme pleace?
The code that I’m using is
lpbc(‘categories=134&posts=7&more=Archive of %name%’);
Thanks a lot!
Hello, really great plugin, I love it.
But is it possible to show only posts from childcategories? Also in the widget I only have a chance to select categories without childcategories.
Sorry, I read one more time the comments and found a solution. But is it possible to sorty ba categoryname?
great plug-in! i’ve been able to adjust the date function to my liking by changing this line:
$thedate = ‘ – ‘.apply_filters(‘the_date’,substr($postinfo->post_date,0,10)).”;
to this:
$thedate = ”.$postinfo->post_date = date(“F Y”,strtotime($postinfo->post_date)).”;
Seems to be working–any thing I should know about the necessity of using the apply_filters function?
Also, would love to use this as multiple widgets, instead of just once. Any chance that will be implemented?
Thanks again!
Very helpful plugin! Thanks! I actually changed it so that it would do the post alphabetized. Now if there were only a way to put the letters between each section (i.e.- A,B,C) that would make my day
Hi
Thanks for the excellent plugin.
I find that the text returned by this -> “more=”Archive of %name%” is like just another post link with the same unordered list styling. It looks like another post. I want that link to more posts of that category to stand out differently.
Please tell me how to style it differently.
Hope I have made myself clear.
Thanks
S.K
Hi – GREAT plugin, thanks!
One question, how can I show a comment count against each article displayed?
S
Great plugin. One question though cant get it to dynamically use a category using
lpbc(‘categories=$agent_category’);
where agent_category is a variable I set and know is populated. Someone please advise.
Thanks
Hasani, have you tried lpbc(‘categories=’.$agent_category); ?
It should work…
Thanks that worked.
I configured this plugin to display a single post (The latest ) from the category “Latest”, which I created in my WordPress category list.
The php I used for doing so, having installed and activated the plugin, was as follows: -
The big idea was, having set everything up in this way; all that remains is to assign every new post to the category “Latest”, in addition to any others as required: This will cause the plugin to auto-display a 160-word excerpt from the latest post thus categorised, following a title-link, on the home page, following which it will display the “More recent posts” link, which will display excerpts of and links to all other posts currently in the category “Latest”.
…But there was a snag: -
I’m not sure why, but I think the plugin may have been caching earlier post entries in the database, which caused it to exceed its maximum allocated memory quota. It was displaying the excerpt from yesterday’s post when another new post had auto-published today as scheduled.
I found that clearing the category “latest” of all but the latest post remedied the situation, and it’s now displaying an excerpt from today’s post.
I’m not really proficient with php; which is why I’m submitting this as a comment, in the hope that it’ll aid performance in the next version, and notify if there’s a bug.
Sharron, please send the code via email (comment did not display it) and I’ll try to figure it.
Hey Alex,
Great Plugin and features. EXACTLY what I needed. EXACTLY !!!
Im running a Membership site that uses WP WishList Member as a membership management tool .. and i needed a plugin that works with it properly to display posts by category that only lists the posts that members have priveleges to view..
Other plugins ive tried just listed EVERY post whether my members were priveleged to view or not..
This plugin Fixes That 100% … where do I paypal ?
Sweet stuff..
Thanks,
Jamie Dunne
awesome thanks!
exactly what i needed……
hi it is great plugin,
i want to display post with excerpt with image
i used code [lpbc posts="5" categories="4" more="more>>"]
will u tell how is this posible
Sona, displaying thumbnail images for those posts is not possible with this plugin without some further coding.
what is further coding after this
[lpbc posts="5" categories="4" excerpts="true" more="more>>"]
pls tell if you have other plugin with him i display my category with excerpts & image
example of this is http://www.bollywoodworld.com/
pls help me
Is there a way to easily order the posts by publish date instead of ID?
I have a blog I’m using for a social media press center. I’m loading in the press releases and back dating them to match when the press release was released. The problem is the LPBC plugin orders them by the ID and not the pub date. So they are listed by the order I dropped them into the admin and not by the publish date I assigned them.
I would like to change this so that they are latest from most recent to oldest by pub date.
any help would be greatly appreciated.
This plugin is AWESOME! Looks like a few people here were looking for the same thing and I agree, it does EXACTLY what I wanted it to do. Got it working in my sidebar. I styled my sidebar using the before_widget and after_widget in my themes functions.php, to create blocks around each widget. I dont know enough about php to understand why this didnt pick that up, but I was able (somehow) to code my styles into your php file. It looks so great i could hug you! Nice and tidy and hiding the categories I dont want! Havent tried the short code in posts and pages, but the possibilities seem endless. thank you thank you thank you. Wordpress should hire you to build this in.
Great plugin! But..how can I know the IDs of my categories?… sorry, I’m newbie.. thanks for ur help.
@erwin – Finding your category IDs
http://www.wprecipes.com/how-t.....ategory-id
Hi. The plugin is working great for me. Just one question. Is there any way I can modify the php code to include a post’s image in the output?
Thanks
I have managed to alter the code in lpbc-archive.php so that the output shows an image (the first image that appears in the original post). The code I have added is inbetween the —— lines. (above and below these lines shows the placing of the code in lpbc-archive.php).
if (isset($excerpts) && $excerpts==true)
———————————————-
$getimage = preg_match_all(‘//i’, $postinfo->post_content, $matches);
$getimage = $matches [1] [0];
$image = “”;
$output .=”.$image.”;
———————————————–
$output .=”.$excerpt.”;
$output .= ”;
I’m not good at php, so don’t know if this is all correct, but it seems to work for me…so far!
sorry, that wont work for anyone, for some reason the html elements I added within the php code have been stripped out when I posted my comment. Won’t work without those I’m afraid.
best relate post plugin that I ever used
Hi there,
loving this plugin and using it extensively. I like being able to display dates, but I didn’t like how the date format was YYYY-MM-DD.
Here’s my adjustment to get the plugin to follow the date format specified in the general settings of wordpress (starting at line 129)
if ($date == true) {
$mydate = substr($postinfo->post_date,0,10);
$myformat = get_option(‘date_format’);
$prettydate = date($myformat,strtotime($mydate));
$thedate = ”.apply_filters(‘the_date’,$prettydate).”;
}
Oops, dunno if you can edit that comment to make the CODE come out right, span tag got eaten up…
Maybe I missed the documentation, but I read thru all the comments and still I haven’t found out how to edit the styling to display categories. I tried editing lpbc-archive.css but it didn’t work. I want to be able to set the padding, the margin and more… I don’t like the default padding. Any helps will be appreciated and sorry for my english.
Fansi
The plugin does not list any categories except Uncategorized. Any reason? I am using it in a widget on the home page.
- Rahul
Would it be possible to alter this plugin to display recently edited posts?