Highlight a Featured Post?

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)

Leave a Comment