Getting Ready for WordPress 2.7: Sticky Post Styling
Sticky posts are a new feature in WordPress 2.7. Basically, it means that you can mark a post as sticky, which means it'll stay at the top of your post listing until another sticky one shuffles it down. More or less like sticky posts on forums.
This has been possible previously as well, with a plugin by Lester Chan.
WordPress 2.7 is out in beta, and isn't due until later this month (late, most likely), but you might want to get your themes ready for this new functionality. You do have to change your post class output to post_class, which I detailed here.
This is what you need to add to your style.css:
That's right, it is just one simple little class, .sticky, for you to add to your stylesheet. The code above will just give the sticky post a grey background color, so how about we do something more funky?
font-size: 24px;
border: 1px solid #bbb;
border-width: 1px 0;
background: #eee;
padding: 15px;
}
That would give us a box with large text, a grey border in the top and bottom, and a light grey background, with 15 pixels padding. Naturally, you'd have to style your sticky posts for your design, this is just to give you something to think about to highlight your headlining posts in the future.
Remember, this won't work with versions of WordPress prior to 2.7!


Want an avatar? Get a gravatar! • You can link to this comment
tried this on cutline theme, dint work, will check it again update you
Want an avatar? Get a gravatar! • You can link to this comment
very nice post man… i was really into how sticky posts would work. thx!
Want an avatar? Get a gravatar! • You can link to this comment
yeah.. doesn’t work with darren hoyt’s agregado theme either!
Want an avatar? Get a gravatar! • You can link to this comment
Doesn’t work. Is there other code to edit? I even checked the 2.7 default theme for .sticky anywhere and nothing.
Want an avatar? Get a gravatar! • You can link to this comment
The beta’s for 2.7 aren’t passing .sticky as a class yet when you use it. The is_sticky() is working though.
Want an avatar? Get a gravatar! • You can link to this comment
I just got it to work. You need to use the post_class().
<div id=”post-”>
Want an avatar? Get a gravatar! • You can link to this comment
Hi, Daniel, can you tell more detail? I am not familiar with the code modification.
Thanks.
Want an avatar? Get a gravatar! • You can link to this comment
Great! It worked, along with the post_class tag!
Mike, just follow the instructions you find via the link on top of this post. After that, follow instructions given in this post here.
Thank you very much, exactly what I was looking for, made my day!