After wordpress 2.7 new function post_class() is added which helps theme authors to apply different styles to wordpress posts.

To use this function you have to add this function in the wordpress loop. on older themes they have added class=”post” to the

in wordpress loops instead of that just add post_class().

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

It can add the following classes which you can use as a hook for CSS-styling:

* .post-id
* .post (or .page or .attachment, depending on the post type)
* .sticky
* .hentry
* .category-misc
* .category-example
* .tag-news
* .tag-wordpress
* .tag-markup

using .category-example you can apply different styles to posts. so if you want to style post within specials category you can simply achieve this by applying style using

/*Your style here*/

So using this you can apply different styles to different categories.

Similarly if you want to style sticky posts you can achieve this by using

/*Your style here*/

About Author

One Response Comment

  • john  July 11, 2010 at 8:59 am

    hi excellent website with cool tutorials and collection of codes