Normally on a blog every post is styled uniform. But wont you think it would be nice if you could style these posts differently. One way to do it is to retrieve the post-ID and then apply style to it. But it is a painstaking process and you would have to repeat the css edit every time a new post is made. Here I am concentrating on a different method. It is by exploiting the post_class(); feature added to WordPress since 2.7. The post loop markup using post_class(); features is given below.
The post_class() generates dynamic class names for each post. They are,id="post-">
1. .post ( default class assigned to posts)
2. .hentry ( hAtom microformat pages)
3. .sticky
4. .category-x ( x is the category slug )
5. .tag-x ( x is the tag name )
For example ,if you have a post assigned to a category named “games”, that particular post will have a generated class called .category-games. You can style all posts belonging to the “games” category with a different style.
.category-games{
background:#fff;
border:1px dotted #ff0000:
}
Following the same example you can style all your sticky posts and post with tags differently. I am using a similar techniques on my site to give different color ribbons on posts.
Source:http://web2feel.com/
0 comments:
Post a Comment