Nerd tech, entertainment, and web development blog

Featured Posts Plugin for WordPress

Version 0.2.1 is the newest version.

Today, WordPress accepted “Featured Posts” into their plugin directory allowing for me to offer automatic updates within WordPress. So even if you do have 0.2 downloaded, please head over to the plugin directory and download Featured Posts.

You’ve probably seen websites with featured posts or breaking news at the top and wondered how to do it. Well now you can easily add it to the front page of your WordPress blog or any category.

Why might you want to do it?
Sometimes you want your visitors to see a post but want to continue adding new content at the same time. For example, you are running a contest and want your visitors to see it first thing, but you want to continue writing about your regular subject. A great way to help your visitors see it is to use featured posts. You just type in the id of your post within the plugin options page and all your regular articles will be displayed normally.

How easy is it to install?
Extremely easy! Just download the file, upload it to your directory and head to the options page. There you enter the post ID you wish to be displayed and whatever image you wish to be shown.

When installing, DO NOT PLACE featuredposts() INSIDE THE LOOP! Read about the_loop here.

The image is taken directly from the post’s gallery.

Full instructions on how to install Featured Posts is located within the readme.txt file.

Wonder what it looks like on your frontpage:
Featured Posts plugin

Can I change how it looks?
You can also easily change the look and feel of the plugin within the separate CSS file so you don’t have to dig through the plugin to find it. This can be extremely useful if your site is using obscure percentages or you want to change the size of the featured posts box.

You can read up on how to change the looks more specifically here.

Do I have to show an image?
No, but it does look better with one. To not show an image just unselect “display image” within the plugin settings page. After doing so you may need to change the CSS though, otherwise the featured posts plugin will probably leave whitespace underneath.

How do I show the plugin on my homepage only?
<?php if (is_home()) { if(function_exists(‘featuredposts’)) featuredposts(); } ?>

How do I show the plugin on a specific category?
<?php if (is_category(’5′)) { if(function_exists(‘featuredposts’)) featuredposts(); } ?>

Want to try Featured Posts?
Check Featured Posts out at the official WordPress directory

Known bugs:
Currently, if a post does not have an image and the ‘display image’ box is ticked then Featured Posts will not display. Simply untick the box and save. This will be fixed in the next update.

The text within the settings page on what PHP code to use is incorrect (it is missing parenthesis). The readme.txt file has the correct usage. It is:

if (function_exists(‘featuredposts’)) { featuredposts(); }

Past versions:
0.1

Change log
0.2 to 0.2.1:

  • Now listed as compatible with WordPress 2.8
  • Deleted rest of $ol_flash

0.1 to 0.2:

  • Changed headfeaturedposts() to echo “alternate stylesheet” instead of “stylesheet”
  • Automatically select image from post to display
  • Renamed posts_add_pages() to featured_posts_add_pages().
  • Renamed posts_options_page() to featured_posts_options_page() and changed add_options_page() to recognize it.
  • Deleted $ol_flash
  • Removed “Featured Posts” text.
  • Added activate and deactivate switch for database
  • Can now choose image size within wp-admin.
  • Now chooses whether to use thumbnail or full image to display based on image size.
  • Can now use a custom description.
  • Changed text below wp-admin form.
  • Changed README.txt to include better directions and use WP standards.
  • PHP code now has better formating and comments.
  • Can now choose excerpt length.

Written: Jun 6, 2009


Related posts »

67 Responses to "Featured Posts Plugin for WordPress"

  • Eric
    January 22, 2008 @ 5:00 am


    Awesome!

    I’ll install it this weekend and give it a go. Thanks for the heads up!

  • Ederic
    January 22, 2008 @ 8:28 pm


    I tried to create something like this manually. I didn’t know there’s a way to do this in an easier way. :)

  • archondigital
    February 2, 2008 @ 11:14 am


    I also manually made one which I still use
    but don’t know how to make it a plugin

    I might give it a shot on my upcoming redesign.

  • Graham Smith
    February 15, 2008 @ 3:19 pm


    Hi
    Thought it was time I popped over to say Hi from Brians site.

    Have signed up to your emails, so only just starting to trowl through your stuff.

    I do have a question that you may be able to point me in the right direction of: I am having terrible issues getting these Top Commentator Plugins to work on my 2.3.1 running K2 theme. I believe I have tried most of the versions going and they pretty much all don’t work, the title shows up in the sidebar but that’s it. No lists of commentators. Just wondered if you had any ideas or suggestions? I know that’s a pretty broad request, but you never know.

    See you and Brian have it and it’s ONE plugin that I would really like to have.

    BTW: See you don’t filter the ScratchBack traffic, awfully brave of you!!! :0)

    Look forward to reading more on your site.

    Regards

    Graham Smith
    ImJustBlogging
    “Web & Blog Ramblings from ‘my’ Gutter”

    • Gary R. Hess
      February 15, 2008 @ 4:52 pm


      I’m not using the top commentator plugin, I’m using the built in WordPress widget that shows the recent comments.

      As for why the plugin doesn’t work for you, I downloaded it to see what was going on. The only thing I can see what is happening is something may be wrong with your settings. You can set it to expire or reset at a certain period. Maybe you have it set to expire too early? I tried it out on k2 RC4 so I don’t think it is the theme.

      Other than that, I would try to contact webgrrrl to see if she knows anything.

      Scratchback brave? Maybe :-P If someone tries something too naughty I’ll just have to delete it.

  • Stephan Miller
    March 10, 2008 @ 11:49 am


    I’ve been looking for this plugin too. Just found it on your site. I had been creating “Featured posts” manually with html in a widget because most of the plugins for do it seemed just about as complicated to use. Installing it now.

  • Martin
    April 15, 2008 @ 3:16 am


    Hi,

    Thanks for creating this awsome plugin, its exactly what I needed, and works a treat with my theme.

    I was wondering is there any way to have the featured post display the postinfo.., ie the date, and author etc.?

    Thanks again its soo what I needed..

    Martin

  • Martin
    April 22, 2008 @ 5:07 am


    Hi,

    Thanks for creating and sharing this plugin

    I think this is an awsome plugin and is exactly what I needed but I was wondering is there anyway to include the author info, and post info etc in the featured post, on mine I just have the title and the excerpt, but I would like it to display (posted in, by.. etc.)

    I’ve tried adding those calls to the plugin but it didint seem to like it..

    Many Thanks

    Martin

  • ark
    June 6, 2009 @ 9:55 pm


    This is cool. Just like making a post sticky but definitely better.

  • Kurt
    June 8, 2009 @ 1:12 am


    Hi,

    I love your plugin, but I had a problem when I updated to version 0.2. It would not show up at all! So for the time being I downgraded back to 0.1 until I can figure out what the problem is.

    • Gary R. Hess
      June 8, 2009 @ 2:43 am


      What version of WordPress are you using? If you are using 2.6 or above, did you try to update the information within the Featured Posts?

      Any more information on what steps you took would be helpful.

  • Brett
    June 8, 2009 @ 1:57 am


    Just a warning to those upgrading “Featured Posts” via wordpress.com. Which I did, except that I didn’t have this plugin but another with the same name, which isn’t in the wordpress directory. So when an update for Featured Posts appeared on my plugins page, I went ahead and “upgraded” it, except of course what it did was blow away my old plugin and replace it with this one, which does something quite different. Wouldn’t be a problem except the download for the old plugin seems not to be working any more :(

    None of which is this plugin author’s fault, of course!

  • Kurt
    June 8, 2009 @ 2:15 pm


    In response to Gary, I’m running WP version 2.7.1 and had Featured Posts version 0.1 working just fine (it’s still in use on my main page). However, I saw there was an upgrade available so I installed it, and I could go to the Featured Posts Options page but it did not show up on my main page anymore.

    • Gary R. Hess
      June 8, 2009 @ 4:19 pm


      That’s very strange. I tested it within other themes (including the default) and can’t seem to replicate the problem.

      The function is exactly the same, so it shouldn’t cause any problems.

      The only thing I can really suggest is after updating, be sure to deactivate the plugin then reactivate it so the database is updated.

  • jack
    June 11, 2009 @ 6:02 pm


    Check out the featured posts plug in on my site http://promma.info
    Over one million hits per week and the plug in is great. Been using it for about a year. However, I think it’s time we changed the colors a bit. Could you please show me how to change this via the CSS file. I’m a bit lost where to put the color code.

    • Gary R. Hess
      June 12, 2009 @ 1:37 am


      Thanks for the compliments and the post idea. I’ll write up specifically how to do it and post it on Monday.

  • jack
    June 12, 2009 @ 6:29 am


    How difficult would it be to make this thing rotate between a few different featured posts? Any plans for this?

    • Gary R. Hess
      June 12, 2009 @ 12:22 pm


      This is definitely in the cards and I have already begun testing it. However, I’m probably going to be quite busy the next few weeks, so I’m not sure how long it will be before I can include it in the plugin.

  • jack
    June 12, 2009 @ 12:45 pm


    Thank you Gary. This is the only featured posts plug in I have ever been able to get to work. Ideally we would like to be able to have a few articles and images in there that rotate.

  • linda
    June 15, 2009 @ 4:34 pm


    great plugin! very simple and easy to use.

    here’s my question/problem, i would like to stack 2 iterations for featured section… rework the plugin folder, php and css with naming structure to something like ‘featureSub’, but continually getting install errors. “Cannot redeclare featuredposts()” can anyone make suggestions?

    • Gary R. Hess
      June 15, 2009 @ 6:54 pm


      Rename every function and every database declaration and it should work fine. It’ll take some work, but it can be done.

    • linda
      June 16, 2009 @ 11:31 am


      thanks Gary. i’ll keep trying and keep you posted. thanks!

  • jack
    June 15, 2009 @ 8:25 pm


    Gary, When you get a chance if you could show me how to edit the colors would be nice.

  • Stian
    June 16, 2009 @ 3:01 pm


    Hi there.

    I tried your plugin on a website, but it wont show up? I use the updated WP 2.8.

    • Gary R. Hess
      June 17, 2009 @ 1:02 am


      Be sure to follow the directions within the readme.txt file. This plugin has been tested within a fresh install of WordPress 2.8 and works perfectly.

  • Blogging in WP | Sublime Oblivion
    June 16, 2009 @ 7:48 pm


    [...] crisp, clean votes on whether you like a comment or not. I wish more people would use it here. Featured Posts – only worth going in to if you make a lot of posts. Global Translator – its main [...]

  • jack
    June 16, 2009 @ 8:31 pm


    Gary can you post how to make the changes to the look. How to post the color codes.

    • Gary R. Hess
      June 17, 2009 @ 1:01 am


      Check out this post. It has a list of all the common changes which can be made within the CSS file.

      If you just want to change the colors, just go to the CSS file and change color: and background:

  • jack
    June 17, 2009 @ 1:03 am


    Yeah I know that. I’m just not sure HOW to do it. I don’t know where to put the code and was hoping you could show exactly where it goes.

  • jack
    June 17, 2009 @ 1:04 am


    LIke i don’t see anyplace to insert for color

  • Stian
    June 17, 2009 @ 3:09 am


    I have done what the readme.txt file tells me, but it still wont show. Am I putting the code wrong anywhere? Can you show me where to put it?

    • Stian
      June 17, 2009 @ 4:23 pm


      Sorted…thanks:-) But a new problem is how to make Read the story >> link to my own language? I tried mod the code, but it stopped working of it:-) Do you have a sugestion?

    • Gary R. Hess
      June 17, 2009 @ 5:46 pm


      You should be able to just edit it-just make sure you don’t accidentally delete anything else. It is on line 68. As well, if you are using any non-english characters you will need to use HTML entities.

  • Hemanshu Tanwar
    June 17, 2009 @ 2:19 pm


    i have followed all the steps mentioned in readme file but the featured post wont show up.

    I have placed the code like this:

    Please do tell me if i am doing it wrong.

    • Gary R. Hess
      June 17, 2009 @ 5:40 pm


      I can’t see what you put because WordPress strips out php code (and rightfully so). The most common problem with installation seems to be the placement of the code. It should be *outside* the_loop. If you aren’t sure what that is, please go to http://codex.wordpress.org/The_Loop and read up on it (shouldn’t take that long).

      If this isn’t your problem, please post the exact error message you receive. If you don’t receive one, please make sure you have error reporting on and try again.

  • Juan Daniel
    June 23, 2009 @ 10:06 am


    Hi,
    I add the plugin and the php code in index.php before any text (so that means its outside the loop right?) It still doesn’t show anything. At the Settings’ Featured Post page i enter the ID (its just a number right?) and I don’t even get the option to select an image having like 7 of them in the post.
    If I want the featured post in the homepage (frontpage), but i have a static page there, what happens?
    thanks!

    • Gary R. Hess
      June 29, 2009 @ 8:18 pm


      Sorry for the late reply, but having it before the text doesn’t sound good. You want to put it right above if (have_posts()), but inside the php brackets.

      Also, featured posts grabs the first image you uploaded to the gallery. This doesn’t mean the first within the post or last in the post but the first one you uploaded to the wordpress gallery.

      It depends on what you mean by static. Do you mean a plain HTML file? If so, it won’t do anything because it is PHP. If you mean you just use the settings within the WordPress to create a “static” page (it isn’t really static) then it will still work.

  • Featured Posts Plugin for WordPress | WordPress News - New WordPress Themes
    June 27, 2009 @ 5:25 pm


    [...] is the original post: Featured Posts Plugin for WordPress Share and [...]

  • weizai
    July 3, 2009 @ 5:37 am


    Hi,

    i tried to put the code into my index.php.

    This error shows:

    Parse error: syntax error, unexpected T_STRING, expecting ‘(‘ in /home/yiwei89/public_html/wp-content/themes/CSSGallery/index.php on line 9

  • weizai
    July 3, 2009 @ 5:54 am


    Hi,

    I solved the error, but the featured post is not showing up.
    Please help me.
    Thanks in advance.

    • Gary R. Hess
      July 3, 2009 @ 7:17 pm


      Be sure to place the code outside the_loop and have a valid ID within the settings page.

  • weizai
    July 3, 2009 @ 8:25 pm


    Hi,

    I put it outside my loop and have a valid ID too.
    But still it will not show up.
    Is it possible that its not suitable with the theme i using?

    Thanks

    • Gary R. Hess
      July 3, 2009 @ 10:26 pm


      I haven’t heard of that happening and I don’t see any reason why it would.

      What theme are you using so I can make sure?

  • weizai
    July 3, 2009 @ 11:50 pm


    I have a plugin called “random featured post”
    Is it because of this that cause your plugin unable to work?

    Thanks

    • Gary R. Hess
      July 4, 2009 @ 2:21 am


      Yep. The two do not play nicely with each other.

  • weizai
    July 4, 2009 @ 2:29 am


    I tried deactivate the ” Random Featured Post”
    But your plugin still wont show up.
    No idea whats going on. :(

  • weizai
    July 4, 2009 @ 6:06 am


    I place the code like this is it correct?

    • Gary R. Hess
      July 4, 2009 @ 2:00 pm


      WordPress strips out php in comments so I can’t see what you wrote.

      I’ll send you an email and just respond in plain text format.

  • Wordsmoker
    July 4, 2009 @ 6:13 pm


    Hi Gary

    Just installed this about an hour ago, and it works fine. It’s perfect for what I was looking for – a way to highlight a particular post while it acts as a sticky. I’m looking forward to playing with the CSS later tonight, mainly because I have no life and things like this excite me.

    I have noticed one thing – the post I’ve highlighted (which uses the “more…” function in WordPress) is shown in full, whereas I normally utilise the “more…” function to truncate the post and allow the reader to see, eh, “more”. Any idea what sort of conflict is going on here? It’s not a showstopper – I’m just wondering.

    Thanks for your hard work on this.

    John

  • Timothy Caron
    July 4, 2009 @ 7:35 pm


    I have recently installed your “featured posts” plugin using WordPress 2.8 and for some reason I can not get it to work.

    On the settings page of the plugin it states to use the following code in the index.php or the page.php

    but when I do I get this error message.

    Parse error: syntax error, unexpected T_STRING, expecting ‘(‘ in /home/timothyc/public_html/wp-content/themes/TimothyCaron/index.php on line 10

    When I use your code I get no featured post display.

    Do you have any suggestions.
    Thank alot
    Tim

    • Gary R. Hess
      July 4, 2009 @ 11:05 pm


      I just double checked what it says within the settings page and I missed the parenthesis around the function_exists.

      It should look like this:

      if (function_exists(‘featuredposts’)) { featuredposts(); }

      I will update the file, thank you.

  • promma
    July 5, 2009 @ 3:55 am


    Still would like to be able to change the colors on this thing but have no idea where to put the code or what the code should look like.

  • francis
    July 6, 2009 @ 2:35 pm


    do anybody know what font type is used in the screen example of this plugin?

    http://impnerd.com/wp-content/uploads/screenshot-1.png

    • Gary R. Hess
      July 6, 2009 @ 9:08 pm


      It is liberation sans bold.

  • francis
    July 6, 2009 @ 3:22 pm


    sorry for to many questions

    how i can change the color to the “READ THE STORY” link? it looks the link is taking my theme css.

    thanx

  • Wordsmoker
    July 7, 2009 @ 1:29 am


    Hi Gary

    Been running this plugin for a couple of days now, and it looked good. Then today I changed the post ID, and now it doesn’t work at all. The code’s still there, outside the loop, everything *looks* okay at the backend, but nothing happens now.

    I tried changing the post ID back to what it was, and still nothing.

    Any ideas?

    • Gary R. Hess
      July 7, 2009 @ 3:07 am


      It looks like the main function is still working since the CSS file is still being loaded to your blog.

      Have you added/updated any other plugins within that time period? If so, that could be the problem. Sometimes the names of functions within the plugins get mixed up with other plugins.

      If you haven’t or don’t have any clue what would be bothering it, try this:

      If you have WP-Cache or WP super cache, try emptying out the cache.

      If that doesn’t work (or you don’t have a cache plugin) try ticking or unticking the display images checkbox and save it. Currently if an image doesn’t have an image and you put ‘display image’, it won’t show the featured posts plugin. This is a known bug and I will fix it as soon as I can get subversion to work again (probably not for a while).

      If that still doesn’t work, try disabling the plugin and reenabling it.

  • Wordsmoker/Gary-Stalker
    July 8, 2009 @ 2:33 pm


    Hi Gary

    Thanks for getting back to me so quickly on this. I had originally thought about WP-Supercache as being part of the problem, but it seems like I’m probably wrong. And I hadn’t installed/updated any plugins between the original install, so I tried your second option first – the “display images” checkbox. It worked!!! Woo!

    As to a bug – all my posts have images in them, so I don’t think it’s that particular sub-point. I also tried checking/unchecking the box, which didn’t work. Also tried exactly defining the image size within the plug-in to match the image within the post – didn’t work either. But as soon as I disabled the “display image” checkbox, it started working again, and across multiple posts.

    In summary – I’ve now got it working fine, but without it displaying any images from the source post. I can live with that no problem, so I’ve tweaked the CSS to reflect these changes.

    I honestly think something like your plugin should be incorporated within the core of WordPress. The “sticky” option is okay, but it doesn’t “highlight” the post one has “stickied” in any particular way, apart from keeping it at the top of the main page. As to your plugin – the fact that you can change the CSS for the Featured Post is an absolute God-send, if you ask me. Endlessly tweakable and hackable, like all good things should be.

    To recap – I’m about 90% happy now. And thanks again for your excellent work on this.

    John

    • Gary R. Hess
      July 8, 2009 @ 8:19 pm


      That sucks that it isn’t working with images for you anymore. I believe this bug in particular is the cause of the problem.

      I should be able to fix it quickly, but I won’t be able to have it uploaded for a while. Subversion isn’t working for me in Windows and I can’t get my connection working in Linux while I am away from home.

  • Kenneth Henderson
    July 16, 2009 @ 6:37 am


    Gary,

    I just installed your plugin on my site and I too am having the problem that the post only shows up if I have “Display Image?” turned off. If I click to display an image, the post will not show up. I hope you can fix this soon. Looks like a promising plugin… however, I will disable until you can get it fixed.

    Thanks,
    Ken

  • johnny
    July 16, 2009 @ 8:12 pm


    Hey Gary,
    I have been trying to figure out how to do this for a while. I was elated when I saw your plugin. I cannot get it to work no matter what I do though. Frustrated but persistent. I put the code outside the loop in Page.php, Index.php, etc… I cant get it to show up. What page php should I be inserting it in? I am inserting because I want it only on my static home page. Also in settings just putting a number for my ID. Anything obvious I might be doing wrong? Maybe it’s my theme? Thanks

    • Gary R. Hess
      July 16, 2009 @ 8:51 pm


      Currently there is a problem with the display image function as talked about within the post.

  • ann
    July 19, 2009 @ 10:35 pm


    the formatting in the body of the post, such as paragraph and h2, get stripped out in the output of the featured post. is there any way that i can have an h2 tag in there that could be used like a subtitle/subheading?

    • Gary R. Hess
      July 20, 2009 @ 3:08 am


      Use the custom description if you want formatting. The reason why it normally strips h2 tags, etc. is because the plugin uses the built-in WP excerpts function, which strips them.

  • Daniel
    July 30, 2009 @ 7:59 pm


    Hi,

    I’ve read the directions, but I’m still having trouble finding the right place to put the Featured Post code outside the loop. I’m using WordPress 2.8.2, opened the index.php file, but don’t know where to put the code. Can anyone tell me the line after which I should place the code, or email me a screen shot of their index.php file with the code inserted? THank you, Dan