With WordPress 2.7 you are able to make a post sticky, so this particular post will be showed on the top always. Before that you had to use a Plugin.
You can activate this setting for a post in the publish area, where you edit the publish date. It’s pretty easy to do.
But what, if you like to format the sticky post? For this matter there is a new function –
post_class(). This gives classes for the different posts, also the class
sticky, if it’s a sticky post.
Additionally are classes for categories and tags available. An example here with some information.
<div id="post-12" class="post sticky hentry category-general category-wordpress tag-survey tag-wordpress">
The above output is a result of following code in the template:
<div id="post-<?php the_ID(); ?>" <?php post_class() ?>>
This function creates different classes, whereas
- the class of the kind of post to show –
- if it’s a sticky post –
- for hAtom –
hentry(check shema microformats)
- all categories, which the post belongs to
- and all tags, which were assigned.
This function can also create additional classes. Very useful if you use a theme before WordPress 2.7 you like to enhance, but already is in use of a class.
Furthermore you can also deliver the ID of a post. You get from this post the classes. For example:
post_class( 'my_class', '9')
The function looks like this in standard.
post_class( $class = '', $post_id = null )