Featured Category WordPress Plugin

About a month ago I began searching for a plugin I just knew existed.  I needed a plugin that would allow me to select a category, a number of posts, and display a neatly formatted list of the applicable posts from that category.

For the site in question, I needed to list recent posts from a “Projects” category. I imagined that there would be at minimum a plugin for posting news items that I could modify. I settled with using The_Loop. At the time I made a mental note “I need to turn this into a plugin.”

Which brings us to Featured Category, my first WordPress Plugin. (Be gentle!)

I tried to follow the WordPress API as closely as possible.

Once you activate the plugin, , simply load it’s settings page and choose the category, the title or “heading” and the number of posts you wish to display.

If the style is not to your liking, simply modify featcat_style.css in the plugin directory. I have included entries for implemented and unimplemented portions to speed things up.

An example from this site. (See home page)

An example from this site. (See home page)

A screenshot from the settings page.

A screenshot from the settings page.

This plugin makes displaying posts from a specific category simple.

Please contact me with any questions. Feel free to post a comment below.

Any feedback will be appreciated.

1.1

  • Integrated CSS into admin panel. Now stores stylesheet in WordPress database.
  • Added instructions.
  • Tweaked a few other things.

1.0.2.1

  • Fixed security issue. Now only administrators can modify admin settings.
  • Deleted trailing spaces at the end of the main plugin file. This was somehow causing conflicts with WP Super Cache plugin. Bizzarre, I know.

1.0.2

  • Fixed path name. (WordPress renamed the installation folder.)

1.0.1

  • Settings page now sets the category drop down box selection when you return to the page.
  • It shouldn’t run in sidebar widgets anymore. (Assuming the content portion loads before sidebar…I may need to tweak this in the future.)

1.0

  • Original release.

Download it now…
Featured Category 1.1 for WordPress 3.0.4

  • http://www.techpp.com Raju

    hi,
    nice plugin this. but can you please show a demo?

  • http://clifgriffin.com clifgriffin

    http://clifgriffin.com has it implemented. :)

    Or is that not what you mean?

  • http://www.techpp.com Raju

    ooppss.. I implemented in my blog as well :) chk it out!!

    http://www.techpp.com

  • http://clifgriffin.com clifgriffin

    Excellent, I’m glad you found it useful.

    Do you have any suggestions for improvements?

    • techiebiox

      hope it also post a thumbnail on it and it can be resized on the admin panel widget

  • James

    Great plugin! Props to u.

    I have two questions.

    1. What CSS code are u using to get that dotted border around your links and the yellow background?

    2. When u install the plugin, the plugin is set to a default category. Now, when I change the category and press Update Options it properly updates it on the front end but when you look at the category dropdown box on the admin side, the value is set to the initial default value.

    I’ll see if there is anything that might enrich this plugin. :)

  • http://clifgriffin.com clifgriffin

    Hi James, I’m glad you like it.
    1. border:dotted; It’s really easy and a nice effect.
    2. Yes, that is “by design” or, in other words, I was lazy. I will eventually update that page to automatically set the drop down box to the correct entry. (I might have to use javascript…haven’t investigated yet)

    I’m writing any suggestions down and will update the plugin with the best suggestions soon.

    Clif

  • James

    As for #1, I see what u mean. I looked at the CSS and there it was. Strange thing is, on my site, it doesn’t reflect the border nor the background color. The background is the same as my blog’s default background color and for the border, there’s no border whatsoever. It may be my computer or my main CSS might be overriding your featcat CSS. Hmmm… It’s not a big deal or anything but it would be nice to have that dotted border showing on my blog. :(

  • http://clifgriffin.com clifgriffin

    What’s your blog url? Also, what browser are you using?

  • James

    My blog is not live yet. It’s local right now. I’m on IE6.0

  • http://clifgriffin.com clifgriffin

    That could be your problem. I have tested it in IE 7, IE8, Firefox, Opera, and Safari. :)

  • Pingback: Leonaut.com

  • http://www.techpp.com Raju

    i have one minor issue, in the sidebar, featured category is interfering with Recent Posts widget, I cant understand why. If I am not clear, you can see for yourself in my homepage on right sidebar

    http://www.techpp.com

  • http://clifgriffin.com clifgriffin

    Wow, great catch.

    The reason is simple: the recent posts widget uses The_Loop AND is on the home page. I will figure out how to fix this and release an update by the end of the day.

    ALSO, I have fixed the problem of the categories drop down box not updating properly. It was simply HTML…no javascript required.

  • http://clifgriffin.com clifgriffin

    Fixed. The new version is up:
    http://downloads.wordpress.org/plugin/featured-category.zip

    Thanks for the feedback both of you.

  • http://www.techpp.com Raju

    perfect now :) cheers!!

  • http://www.techpp.com Raju

    Hi, I guess a bit too soon. There is a bug in this release. The name of the folder has been changed to “featured-category” and it was “featuredcategory” before. I am getting this error – “Warning: file_get_contents(/home/xxx/public_html/wp-content/plugins/featuredcategory/featcat_style.css) [function.file-get-contents]: failed to open stream: No such file or directory in /home/xxx/public_html/wp-content/plugins/featured-category/featured_category.php on line 110″

    I have fixed it in my local anyway.

    http://www.techpp.com

  • http://clifgriffin.com clifgriffin

    That is really weird. I don’t know how that happened.

    I’ll take a look at my source. I definitely didn’t rename any folders.

  • http://clifgriffin.com clifgriffin

    And fixed!

    The original version you downloaded was a version I packaged myself.

    When wordpress creates the zip file, it picked its own name for the plugin directory.

    This shouldn’t be a problem in the future.

    Thanks again for helping me iron this stuff out!

  • http://www.techpp.com Raju

    oh ok… my pleasure :)

    http://www.techpp.com

  • http://techpp.com Raju

    Hi,
    There is an update available for this plugin. Major update?

    Raju

    • http://clifgriffin.com clifgriffin

      Previous update. :) When I uploaded 1.0.2 I didn’t update the version number in the main file so it appeared to be 1.0.1.

      This version is the one with the correct path. (the bug you reported)

      • http://techpp.com Raju

        oh ok :) I am chased by my web host to reduce my resource usage :( Missing this cool plugin since few days :(

        • http://clifgriffin.com clifgriffin

          That’s super lame. What host are you using?

  • Steve

    This is actually a very neat plugin. How can I change it so it will display categorized pages as well?
    Thanks!
    Steve

    • http://clifgriffin.com clifgriffin

      I would have to investigate it.

      You would have to rework this query:

      $my_query = new WP_Query("cat=".$category."&showposts=".$num_posts);

      Right now it only pulls back posts. I’ll investigate how to change the query to include pages and consider including it as an option in my next version.

  • http://www.xnascratch.com Allan Chaney

    Clifton,

    I really like this plugin. It’s a simple single purpose plugin but what a very cool feature. Thanks so much for sharing it.

    My suggestion for future revisions would be to allow the user to modify the style using the existing Featured Category Settings form. This would broaden the appeal of the plugin by making it customizable to those who don’t want to delve into HTML coding. You could have some drop down fields that allow the user to type in a color code, choose a border type etc. And then clicking update would update the featcat_style.css.

    Again, great plugin!
    Allan Chaney

    • http://clifgriffin.com clifgriffin

      Thank you for the kind words. I prefer effective, single purpose plugins rather than plugins that can do everything, but nothing well.

      Your suggestion is a good one…and one I’ve been thinking about doing but hadn’t motivation. I will definitely include this in the next version.

      Clif

  • http://www.anadguy.com Melton Cartes

    Hi, Clif:

    Thanks for your work. I’m going to try it out.

    However, I’m looking for something slightly different. I’m going to blurt in case you or someone else knows of a solution…

    1.) Is it possible to have the The Loop on index.php or home.php show a Page (content created in the Admin panel for Home, for instance) as well as Recent Posts beneath that Page’s content?
    I hand-coded content into my Index.php to create a fake version of this idea on my site (http://www.anadguy.com) and on this non-profit site (http://www.abdf.org) but I would prefer to allow that to be edited by others as any normal page and not have me be the bottleneck.

    2.) If not using The Loop for Recent Posts is there a way to show graphics or images that are part of these “recent posts” using Excerpt (or something else)? The “Watch videos of our recent performances.” section on this non-profit site attempts to do that, but of course doesn’t show “videos” or even thumbnail graphics… (http://www.albanymusic.org).

    3.) Selecting a category is great. But is there a way to show Recent Posts for all categories except Cat ‘x’?

    Thanks!

    mc

  • http://www.technofinger.com Kenneth

    Hey!
    Loving your plug-in but would love it if you can show me a bit of code that will display an excerpt or whole post please!!! I’m useless at php/css so any help would be much appreciated!

  • Sarah M.

    I’d like to know how to add an excerpt as well please!

    Also, I would like it to show up in the sidebar. Any ideas?

    • http://clifgriffin.com clifgriffin

      Because of the way the plugin is implemented, a sidebar implementation would be very difficult to achieve and essentially result in a rewrite.

      Adding an excerpt is easier but I’m not sure how that would be formatted.

      			foreach ($my_query->posts as $cpost)
      			{
      				setup_postdata($cpost);
      				echo "
    • "; echo "ID); echo "">"; echo $cpost->post_title; echo ""; echo "
    • "; }

      You would simply need to echo $cpost->post_excerpt wherever you desire I think…I could be wrong.

      Let me know if you run into troubles and I’ll give you some help.

      Clif

  • Peter Lurie

    Hi Cliff!
    I have used this plugin, and it has appeared on the front page. I gather that this is a “given”… since we don’t include any php code on our Index page.

    I have 2 issues:
    1) I selected 5 items, and I get a zillion.
    2) I would like to display the “more” tag on the front page, and by inserting the correct code on the index page, I still get no change to the display.

    Any suggestions/ideas?
    Peter

    • http://clifgriffin.com clifgriffin

      Hi Peter,
      When you select display 5 items, it displays all items from the selected category? Is this true no matter what category you pick?

      I don’t understand what you mean on number 2, could you explain what you’re trying to accomplish?

      Thanks,
      Clifton

  • hendry

    Nice plug in…

    i have install your plugin,…

    my question, how to MOVE this plugin to SIDEBAR,
    thks

    http://www.pakkatnews.com

  • http://theafternoonbreak.com Chris

    Hi Clifton,

    This is a great plugin. Can you help with the excerpt? I installed the bit of code you mentioned earlier but doesn’t seem to be working. Thanks so much.

    CHris

  • Pingback: Wordpress Plugin Updates « Clifton Griffin

  • http://www.michael-jackson.mobi-fr.com Michael

    Super plugin mille merci
    lot of thanks

  • http://westonparkbaptist.org cheryl

    Hi Clifton,
    I can’t seem to get any featured category to show up on the home page of my site. Any suggestions?
    thanks,
    cheryl

  • http://westonparkbaptist.org cheryl

    Just looked a little deeper and it’s appearing on my blog page (talkin’) not the static homepage where I want it to appear. Is there a way to make it appear on the static home page?

    • http://clifgriffin.com clifgriffin

      There’s no easy way to do this that I know of. The code has to be executed from a WordPress page.

      Sorry :(

  • http://askrealgamers.com Michael

    I was looking at your Featured Category plug-in and another but neither show all my categories. Both show the first category I made, site news, but none of the others. Any ideas why? Could it have to do with Permalinks?

  • Pedro

    How to move this plugging? I would like to put it anywhere on my frontpage…

    • http://clifgriffin.com clifgriffin

      I can’t be moved in this release. Sorry.

  • http://www.ubisanmanagement.co.uk Colin

    Hi Clifton

    Great plugin – really useful for a lot of sites I’m working on at the moment.

    Is it possible to have more than one featured category? I know this kind of defeats the purpose of having a featured category plugin but I’ve got a client with lots of news items spread over several categories and he wants to draw attention to them on the front page.

    At present, it looks like you can have two but I had a quick look at the featured_category.php file to see if there was a value that could be changed there and couldn’t see one.

    Am I missing something or is it not possible?

    Cheers

    Colin

    • http://clifgriffin.com Clifton Griffin

      The plugin doesn’t support multiple categories, however posts can be tagged with multiple categories. So your best bet would be to add posts you want to feature to a separate category (maybe “Featured”?) and then point the plugin to that category.

  • spin

    Any word on how to add an excerpt. I really like the ease of use but the client isn’t going to go for it if we cant have a little more description.

    Any thoughts would be greatly appreciated.

    Thanks
    Bonny

  • http://qzmcwjdibpjy.com/ curnmtlb

    q8PLaU tguzglofrrzv, [url=http://wakigrngnhag.com/]wakigrngnhag[/url], [link=http://pdpegtzrztby.com/]pdpegtzrztby[/link], http://tpzksarlrrgr.com/

  • http://www.wordpress.auburnclient.co.uk/ Jane

    Hi Cliff,

    Is it possible to add the featured category to the home page if it is a static page?

    Thanks,
    Jane

  • Taylor

    I want to add images to each item (like techcrunch.com or makeuseof.com). Is there a way to impliment this using the post image?

    • http://clifgriffin.com clifgriffin

      It isn’t possible as written, but I’m sure making such an addition would not be too difficult if you are familiar with PHP.

  • http://ps-ik.gunadarma.ac.id/ dhan

    thank for that information, it so usefull

  • Sara Paxton

    Looking for assistance with the FeatureMe plugin. It only appears on the blog link on my site and not in the featured posts box at the top of the page.

    Since this is not working appropriately on the static home page that we’ve set up – can you tell us how to replace the featured posts with an image or other object?
    Additionally, we are trying to add a custom logo to the top of the page – any feedback on how to do this? Ive tried locating the spot to edit within the header, bu without any luck

  • http://www.healthonlinezine.info/ hezy

    hi cliff,

    how to add this plugin in the sidebar? because i didn’t found feature category on widget page. Does it use php code?

    • Anonymous

      It isn’t a sidebar widget. It’s designed to be positioned above the loop on the homepage. Sorry!

  • http://twitter.com/city_ville cityville

    sometimes and I am very pleased to report this latest contribution is actually kinda effective and enormously superior than 50 % the various other trash I read today

  • Zinxu

    Will be more than one Featued Category ?

  • http://twitter.com/savory_girl Suzanne

    I’m pretty sure this is exactly what I’ve been looking for, but since I’m new to this I’m having a hard time getting it to work.  All of the other plug-ins I’ve downloaded have also come with a widget that appears on my widget page for me to drag & drop into the appropriate page or sidebar folder.  While I understand this isn’t meant for a sidebar, how do I get the widget so I can use this where I want it on my site and get it to actually work?  It’s activated on my plug-in area and is showing up in my settings, but I don’t see that it’s actually appearring anywhere on my site and I would really like to use it on two different pages. 

    Thoughts on what I’m doing wrong??

    • Anonymous

      Hi Suzanne,
      I wrote this plugin many moons before I ever looked at widget integration. As written, it is supposed to put the “widget” at the beginning of the loop, but it unfortunately doesn’t register a widget that you can place where you wish.

      I realize that this might mean that the plugin isn’t usable in your case…I apologize. If I had more time, I’d redo it properly.

      Clif

  • Adam

    It’s exactly what I am looking for, but it doesn’t work!  It doesn’t show up in widgets…. 

  • Boki

    It would be nice to improve this nice simple plugin with a few lines of post’s text below post title (and option for number of words to display before putting “…” at the end)
    and btw. is it possible to put few different categories vertically and change order of putting them

    structure:
    CATEGORY TITLE
    - POST TITLE
       – FEATURED IMAGE
       – FEW LINES OF POST’S TEXT …

    CATEGORY TITLE
    - TITLE
       
    - FEATURED IMAGE
       
    - FEW LINES OF POST’S TEXT …
    .
    .
    .etc…

    so I could make my homepage like this      http://www.tacno.net     – scroll to the bot of page

    PS nice work anyway – ty