Update: Category Posts Widget has been updated to version 3.0!
I just released a long overdue update to Category Posts Widget. At the time of this writing, it has been downloaded over 23,500 times and has an average of 4.5 stars from 22 people!

CPW 2.0 has been included with Press75 themes for sometime now. I haven’t heard any problems with it yet so it should be pretty stable. I updated it to use the new widget API so it is only compatible with WordPress 2.8 and above. It also supports a little plugin I wrote called Simple Post Thumbnails.
Sorry about the first version of this post, the comments stripped out some of the code. Here it is linked:
http://www.thomascallahan.org/posting/wp-cat-widget-modded.txt
That’s a modified version of “cat-posts.php” in the plugin.
Hi James,
This plugin is just what I needed, thank you and well done!
Feature Request, can you limit the length of the posts without using the excerpt or more tag.
Cheers,
Birkoff
Hello,
I’ve uploaded the plugin & activated it, then dragged it into sidebar1 in the widget area, but nothing shows up on my site – what code needs to be in the sidebar to make it appear please?
Thanks,
Dave
Hello there,
I changed a really small portion of your script to be able to manage the OFFSET of the posts. This way if you want multiple posts but different from same category you need the offset thingy.
This is what i have changed:
Modified:
$cat_posts = new WP_Query(“showposts=” . $instance["num"] . “&cat=” . $instance["cat"]);
to
$cat_posts = new WP_Query(“showposts=” . $instance["num"] . “&cat=” . $instance["cat"] . “&offset=” . $instance["offset"]);
//for the query
and added
<label for="get_field_id(“offset”); ?>”>
:
<input style="text-align: center;" id="get_field_id(“offset”); ?>” name=”get_field_name(“offset”); ?>” type=”text” value=”" size=’3′ />
right after
<label for="get_field_id(“num”); ?>”>
:
<input style="text-align: center;" id="get_field_id(“num”); ?>” name=”get_field_name(“num”); ?>” type=”text” value=”" size=’3′ />
This way i added the offset thingy in the form in widgets.
Thanks for the great plugin!
Thanks James–this is a very useful widget.
I ran into one problem: when using it on single pages, I have other widgets below it that display content like the_author() from the post on the page. Category Posts never resets the loop it creates back to the main loop, so when the_author() is called in a subsequent widget, it retrieves the author of the last post from Category Posts.
The fix is easy: I just called wp_reset_query() somewhere between lines 62 and 67 and everything worked as expected. It just took me a long while to figure out because I thought it was a problem with my own widget below!
How do I include this on my blog manually if I don’t want to use widgets?
Hi James, thanks for this great plugin. I just have a question. Is there a php snippet I can use to call this function from within a template file instead of using widgets in WP-admin?
Again, thank you for this super plugin! I was really happy to find it after days of Googling.
P
This is a great plug-in, just got one little thing….
When I turn on excerpts, they are heavily indented. How can I fix this? Is i t my CSS that is doing this?
Here is an example:
http://csbconline.net/wp-content/uploads/2009/10/cat_post_example.png
Thanks for making this great plug-in!
Hi,
Im currently redesign my blog with your category-post plugin within it. It was really helpful! Thank you very much James.
But, is there any way so the plugin can display random post from the selected category?
Thanks before.
Thank you for this plugin. In a previous version of the plugin I believe the class for the active link would change however this has disappeared on upgrade. Any plans to restore this feature?
Thanks for the awesome plugin! It’s so great actually, that I want to use it for my all my recent posts.. as I have yet to find one that uses the custom excerpt AND lets you pick the thumbnail to use (via simple post plugins). If i created a separate instance of the plugin, how hard would it be to tell it to pull posts from all categories versus just the one?
and for those who want to use this w/o a widget aread check out “amr shortcode any widget”. it lets you call any widget from [do_widget "widget title"]. found that today and it works a treat.
Sup bro! really nice plugin! congrats!
But i’m really curios how i can handle the script manually? i dont use widgets in my template!
Thanks in advance
-Cheers
Great plugin. I might improve it to provide also the number of comments. I will notify you if i do
Pingback: Sure Fire Way To Lower Bounce Rates | ocondesign
Thanks for plugin. It very nice.I will try.
Hi, this is a really simple and cool plugin and is just what I need.
Only thing is that it seems only to show one image for all the diferent categories.
I use the widget 4 times in one place (to show 1 post from each of four categories) and it shows the same image that I uploaded in one category for each of the others.
Any ideas on how to fix?
Thanks again.
Yeah, I’d really like to use this for a WP site’s sidebar, but I don’t want the widget as it’s currently done (because too much WP’s CSS is now dedicated to other areas of the site that look wrong when I just drop the widget in as-is). I have my own unique-styled div all ready to house it. What is the PHP code I can just drop into the sidebar.php page inside the to call up the function? I just want the top 3 headlines to display in my div from the “Blog” category. Thanks.
Would like to have the posts listed alphabetically rather than having the most recent at the top. Any way to configure for this display order?
Great plugin otherwise! (Almost) exactly what I needed!
Thanks, great plugin. I need to make one slight amendment to it. I want to create a tabbed sidebar with three categories. I want to be able to only show posts for the selected category in the side bar when you click on the current tab.
By default the widget allows you to choose a default category to show but you cannot change the list of posts that appear in the sidebar. I want it to change the list of posts when you select a different category tab in the sidebar. Hope this makes sense.
Hi
Thanks for this plugin. It’s exactly what I was looking for.
However, is it possible to display the posts in REVERSE chronological order starting with the oldest ? I would really LOVE that feature
In fact, it’s available in another similar plugin. The only problem with that plugin is it only allows 1 widget whereas yours seems to be unlimited
Hi James – Thanks for the plugin. I came across a situation I needed but it doesn’t cover, so I will give you the fix.
I have a category archive page, using wp-pagenavi to o handle paging.
My theme is based on the carrington-blog theme, at least the part which handles the archives page.
I also have your widget on that page, displaying items in the same category.
For reasons I haven’t been able to figure out, your plugin uses the value of “posts per page” set in the theme settings admin page. I would like your plugin to use its own setting of course for the number of posts to display.
This may be due to a filter or something I am not aware of, but I have a work around for you.
First, set the query in your plugin to have nopaging=1:
// Get array of post info.
$cat_posts = new WP_Query(“posts_per_page=” . $instance["num"] . “&cat=” . $instance["cat"]. “&nopaging=1″);
This will actually ignore the number of posts, but the next piece of code fixes that.
We change the loop structure in the plugin to:
$post_count = 0;
while ( $post_count the_post();
….
$post_count++;
endwhile;
That’s it!
Even without my theme/plugin combo, it should still work as before. But with the combo, it still works!
So please consider adding this to the next version, users of complex magazine style themes will thank you!
oops, that while statement is:
while ( $post_count < $instance["num"]) : $cat_posts->the_post();
Sorry …
I changed this line:
$cat_posts = new WP_Query(“showposts=” . $instance["num"] . “&cat=” . $instance["cat"]);
to this:
$cat_posts = new WP_Query(“showposts=” . $instance["num"] . “&cat=” . $instance["cat"] . “&orderby=id&order=asc”);
And that gave me order using ids in ascending..Just in case someone was seeking for the answer