Right now, every blogger has know WordPress as easiest and nicely support publishing system. To create more sophisticated and personal blog. Blogger chooses WordPress as they Blog Engine. Some featured that we can use to create more unique blog is style some category differently.
In WordPress do this tricks is quite simple, we only need added extra code and added CSS Style for this area. Example we will create different style on category 5 here the code. Put this code on your WordPress Loop or you can directly edit on your index.php
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php if ( in_category('5') ) { ?>
<div class="post-cat-five">
<?php } else { ?>
<div class="post">
<?php } ?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
<div class="entry">
<?php the_content(); ?>
</div>
<p class="postmetadata">Posted in <?php the_category(', '); ?></p>
</div>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
I will explain the code, on the code above we put some condition, if the loop find post in category 5 the div class name will be post-cat-five but and other class name will be post.
The next step is added CSS style on your style.css, here an example
.post-cat-five {
background: #efefef;
padding: 15px;
border: 1px solid #ccc;
}
.post {
border-bottom: 1px dotted #999;
}
That’s it, Now each post in Category 5 will be style differently. I hope today tutorial how Style Posts From Some Category Differently useful on you
Photos courtesy of Kanegen flickr account




Pingback: wp-popular.com » Blog Archive » Style Posts From Some Category Differently # WordPress Tricks & Tips