Sticky Posts in WordPress 2.7

One of the new features in WordPress 2.7 is “sticky” posts, which will always appear at the top of the home page. The option is pretty well hidden, so unless you know where to look for it, you probably won’t find it.

In the edit or create post screen, there’s a publish options box which lets you specify the visibility for that post, with an ‘edit’ link next to it.

publish options.jpg

Click the edit link and it will expand the box to show the options, including a ‘sticky’ checkbox.

Publish Options Expanded.jpg

You can test for sticky posts in your theme using is_sticky() and change the appearance to highlight those posts.

In the theme’s index.php, alter the class of sticky posts with code similar to this:

    <?php while (have_posts()) : the_post(); ?>
       <div class="post <?php  if (is_sticky($post_id)) { echo 'sticky'; } ?>" id="post-<?php the_ID(); ?>">

Finally, add a ‘sticky’ style to the theme’s style.css, for example:

.sticky {
	background: #dde;
	padding: 5px;

Leave a Comment