Question

I would like to "highlight" a featured post above all other posts with a special indicator.

Is there a feature in WordPress that will do this or do I need to install a third party plug-in?

I am using a custom WordPress install (not WP hosted).

Was it helpful?

Solution

Use the "sticky" feature.

In the "Page Attributes" metabox (labelled as Publish), if you click the "edit" link next to the Visibility option, there is a checkbox which allows you to "Stick this post to the front page".

Unless a theme overrides the default query, that post will show up above all the others. In addition, it adds the class name "sticky" to the attributes returned by post_class(), so you can style it however you want.

alt text

To add some text to your featured posts and highlight them, add a function like this inside the loop in your index.php (or loop.php, etc., depending on your theme):

if (is_sticky($post->ID)) echo '<span class="featured">Featured!</span>';

You can do the same thing with the css :before property, like this:

div.sticky h2:before {
     content: "Featured! ";
}

(assuming you're using h2's to display the titles of your posts, and you want to add the text before the title)

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top