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

Comments

  1. James says

    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. :)

  2. says

    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

  3. James says

    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. :(

  4. says

    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.

  5. says

    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

  6. says

    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!

    • says

      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.

  7. says

    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

    • says

      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

  8. says

    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

  9. says

    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!

  10. Sarah M. says

    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?

    • says

      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

  11. Peter Lurie says

    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

    • says

      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

  12. says

    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

  13. says

    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?

  14. says

    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?

  15. says

    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

    • says

      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.

  16. spin says

    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

  17. Taylor says

    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?

  18. Sara Paxton says

    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

  19. says

    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

  20. says

    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??

  21. says

    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??

    • Clifton Griffin says

      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

  22. Boki says

    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

Trackbacks

  1. Featured Category WordPress Plugin |…

    Featured Category allows you to display recent posts from the category of your choosing. You are able to customize the number of posts, the style they are displayed in, and the heading used to describe. It is perfect for display recent news, projects, …

Leave a Reply