Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 7 down vote accepted

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)

share|improve this answer
    
Wow. Great response and I dig the screenshot too! That's great about the "sticky" class, but is there anyway to insert plain-text (such as the words "Featured") into an HTML element? –  user1462 Nov 3 '10 at 23:27
    
You could do that in your template files. I'm editing my answer to cover that. –  goldenapples Nov 3 '10 at 23:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.