Category Posts WordPress Widget
I present to you, my Category Posts Widget WordPress plugin. This isn’t my first WordPress plugin by any means, but it is the first one I’ve released to the public. This one actually arose from my most recent project, nukoda.com, where I needed to display the most recent posts from a category in the sidebar. I went searching around for an existing solution, but didn’t find one that suited my tastes. I wanted a simple widget, that allowed me to:
- Specify how many posts to show
- Set which category the posts should come form
- Designate how many of the widgets I needed
My search didn’t yield anything that fit my criteria and my criteria only so I ended up creating one. The documentation for creating a widget with dialogs and controls is not very good and almost nonexistent so it took me a couple days of hacking to figure it out, but here it is.
Update: Category Posts Widget has been updated.
Installation
- Download the plugin using the link above.
- Upload it to the plugins folder of your blog.
- Goto the Plugins section of the WordPress admin and activate the plugin.
- Goto the Widget tab of the Presentation section and configure the widget.
Donate
This plugin was created by me and is made available free of charge. However, if you would like to show your appreciation, you can donate via PayPal by clicking the donate button in the sidebar. All funds go towards getting me into college so I can get an education.
Chris B on October 24th, 2007
awesome plugin, I have not yet tested it. but when I say this one thing come to mind:
Can I display this plugin in a widget in my sidebar, based on the category you are in.
example: you go to a blog, click (category A) you now see all the posts under category a on your blog, all of them, paged or whatever.
ok, what would be nice is to display a widget in the sidebar that was dynamic and would detect that I am in category A and will display category a top posts?
Get my thought, is this possible with this plugin or is this a killer suggestion to get built in.
I want to know because if this aint built in, I might download this plugin and start programming it to make it possible for myself.
Thanks,
CB
Aaron on October 24th, 2007
this is great and easy to use! any way to mod it to show an excerpt from the post? cheers! good work!
Weblog Tools Collection » Blog Archive » WordPress Plugin Releases for 10/25 on October 24th, 2007
[...] fixes and everything about blogging, especially with Wordpress. Go ahead, subscribe to our feed!Category Posts Widget displays the most recent posts from a specific [...]
James on October 24th, 2007
CB-
That feature is not built in. However it sounds like an intriguing idea and I might write a different plugin that does that when I have time.
Aaron-
Indeed you can. I can add an option in the configuration dialog to show excerpts when I have time.
Thanks for your comments. I really appreciate it.
Sergio on October 25th, 2007
thanks for the plugin!!!
Aaron on October 25th, 2007
Thanks, James. I can’t find another plugin out there that does it. Would be really appreciated! Cheers!
livemtl on October 25th, 2007
RE: Aaron…
I would like to be able to include a thumbnail as well with my recent posts, as I use it for the category ‘Video.’
This is a great plugin, Thanks!!
http://www.livemtl.com
WordPress Plugin - Category Posts Widget at WordPress Themes, Plugins, Blog Tips, Make Money Online >> WPthemesplugin.com on October 25th, 2007
[...] Visit & Download [...]
WordPress Greatest Hits widget » Justin Henry's green galoshes on November 11th, 2007
[...] plugins directory shows an existing plugin that suits this need. James Lao built a plugin that shows posts from a specific category. From the looks of it, I like his plugin better than my hacked one. « Nate Koechley on [...]
Peter on November 18th, 2007
Love this plugin, in use right now at http://www.obsessedwithfilm.com
I have styled it a little differently though, but I only want this to happen for one widget. I want to be able to have more category post widgets but styled normally… I thought simply installing the plugin again but named something different could achieve this, but sadly it doesn’t seem to be that simple. How can I go about having more than one widget but only having the one main box styled like I have it currently.
Jeroen on November 27th, 2007
Great widget/plugin! This was what I was looking for! Thanks a lot!
A little feature-request if you have the time to improve it even more:
1) One major widget with the possibility to include several categories, but without overlapping eachother (sometimes posts fit in both categories).
2) the option to include two categories in one widget (sometimes similar categories can compliment each other).
moshu on November 27th, 2007
Any chance to get a non-widget version of this?
matthew on November 29th, 2007
HI,
i want to use your widget with SBM in WP 2.2.2 but it keeps crashing–any work arounds?
thanks
Matt
Turnip on December 22nd, 2007
Every was working fine, but now the widget is showing an incorrect link for each article. It grabs the correct article titles, but directs to links from another category. any ideas?
Gwyneth Llewelyn on January 6th, 2008
Thanks for doing this widget! I was a bit desperate to get a set of consistent widgets on a new blog that showed up the last few articles on several categories/RSS feeds. The default RSS widget does give you a link to the feed, but using RSS feeds for the categories on the same blog was not working (they rarely — if ever — got updated). Also, it was overkill, when WP does such a good job at showing the latest articles on categories.
Inspired by the Accessible News Ticker wordpress plugin 0.3 by Pixline — which uses both RSS feeds and category links, I did a small change to get the title of your cat-posts widget to display the orange RSS icon with a link to the RSS feed for that category.
It’s just one line of code (line 21):
echo $before_title . "<a href=\"" . get_category_link($cat_id) . "feed" . "\" alt=\"RSS feed for $title\"&rt;"
. "<img src=\"/wp-includes/images/rss.png\" height=\"14\" width=\"14\" alt=\"RSS feed for $title\" /&rt;</a&rt; ". $title . $after_title;
Of course, I should change the widget code to have a further checkbox saying “add RSS icon to this category feed”, but I was lazy to do more than the above
(I’m just learning a bit about widgets and how they register with WP)
Cheers and thanks again for a great WP widget!
Gwyneth Llewelyn on January 6th, 2008
Oops, small HTML mistake above
echo $before_title . ""
. " ". $title . $after_title;
Gwyneth Llewelyn on January 6th, 2008
You would certainly benefit from some sort of comment previewing on your blog to prevent me to “spam” the comments section correcting bad HTML formatting inside the <code> tag
echo $before_title . "<a href=\"" . get_category_link($cat_id) . "feed" . "\" alt=\"RSS feed for $title\">"
. "<img src=\"/wp-includes/images/rss.png\" height=\"14\" width=\"14\" alt=\"RSS feed for $title\" /></a> ". $title . $after_title;
jahan on January 10th, 2008
Love the Plugin. Question for you – how can I get more than 9 Category post widgets in my widget sidebar. Also how can I get more than 15 posts shown for each category. I am trying to use it to organize a shop and I am running out of space for different posts as this limits me to 140 posts shown on my sidebar and i want to have at least 300. You can see what I am trying to do by looking at the url of my post.
jahan on January 11th, 2008
nevermind – got it – i went into the plugin and changed all the 9’s to 30 and the 10’s to 31
and it works
Paul on January 15th, 2008
Nice plugin. Thanks for sharing it.
Easily Display Category Content - Bloggeries Blog Forum on January 16th, 2008
[...] link to this plugin besides your website home? I believe that this is the url for the plugin. Category Posts WordPress Widget » James Lao __________________ Powerfull Niche Marketing CMS | Cheap and Reliable Blog [...]
Bill on January 30th, 2008
Thank you for this plugin, James. I thought I was going to have to cobble together my own thing, then at the last minute found your solution.
I have two suggestions, the first one being kind of important. In terms of the mark-up for the widget output, I think your widget should follow the format of most other widgets. Coming out of the widget unique ID, you go right to a tag — look at other widgets — there are some div’s thrown in there, which then is useful for writing css (I’ll go into the plugin and make these changes myself).
My other suggestion is to add the option in the widget preferences of whether to add a “more” link at the bottom of the list that links to the same category the links are being pulled from. This more link would also be in the list, but appear at the bottom. You would also need to wrap it in a so that we could format it as needed (for example, link ).
again, thanks for your work.
Charlie on January 30th, 2008
I’m experiencing the same issue as described in comment 14 by Turnip – I’m displaying the proper title, but it is linking to another post in another category.
Additionally, I am quite interested in the ability to show excerpts from posts. Thanks so much!
Adam on March 8th, 2008
Hey- this is exactly what I’m looking for- however when I install and activate it with NO OTHER PLUGINS active i get this:
Fatal error: Call to undefined function: wp_register_sidebar_widget() in /homepages/23/d236268553/htdocs/wp-content/plugins/cat-posts.php on line 99
I then have to log on FTP and manually remove the plugin.
The only thing I can think of is that I’m using the K2 Theme with Sidebar manager active- however, all my other plugins work fine.
Any help would be great- thanks.
Dani on March 10th, 2008
How can I add POST date?
the surg3on on March 21st, 2008
Hello,
I love the plugin. I am hoping you can tell me where to modify the code so that I can make the category Titles, into links that go the the category and shows all of the posts for the category.
Can you please tell me what line of your plugin’s source code to modify?
rhand on March 23rd, 2008
I love your widget James. But I would love to add a post excerpt to each recent post title. Any idea how I can achieve this? Blue anvil’s plugin @ http://blue-anvil.com/archives/create-a-wordpress-recent-posts-widget used to work like that, but it doesn’t work in WP 2.3.3 anymore. I hope you can help me out. Cheers, Rhand