WordPress — How To Style The Posts On The Basis Of Category

December 20, 2010

WordPress — How To Style The Posts On The Basis Of Category

Customizing WordPress and styling your weblog is the play of your imaginations. WordPress opens up the plethora of opportunity for making the customizations work out for you. Here is a quick tip for customizing different category in different style.

Copy the code given below to functions.php and create & replace the stylesheets (stylesheet1, stylesheet2, stylesheet3) with your specific css filenames.

function custom_cat_style()
 {
 ?>
 <link rel="stylesheet" href="<?php bloginfo('template_url')?>/stylesheet1.css" type="text/css" media="screen,projection" />

 <?php
 if( in_category('1') )
 {
 ?>
 <link rel="stylesheet" href="<?php bloginfo('template_url')?>/stylesheet1.css" type="text/css" media="screen" />    

 <?php
 }
 elseif ( in_category ('2') )
 {
 ?>
 <link rel="stylesheet" href="<?php bloginfo('template_url')?>/stylesheet2.css" type="text/css" media="screen" />

 <?php
 }
 elseif ( in_category ('33') )
 {
 ?>
 <link rel="stylesheet" href="<?php bloginfo('template_url')?>/stylesheet3.css" type="text/css" media="screen" />
 <?php }    else {     ?>

 <?php
 }
 }

add_action('wp_head','custom_cat_style');

 

Join 37,807 others and get free tutorials & tips on design & development using Wordpress on, Thesis & Genesis!

Need help with Wordpress, Thesis or Genesis?

Are you a designer or a developer looking for a hand with Wordpress, Thesis or Genesis? Or perhaps want to save time with a project? Get in touch and let's get the ball rolling! Check out our Thesis development, PSD to Thesis & other services.

Comment on WordPress — How To Style The Posts On The Basis Of Category

You can add images to your comment by clicking here.

Previous post:

Next post:

X

Wordpress, Thesis, Genesis tutorials from Binary Turf — one tutorial a day. Subscribe & sharpen your web design skills.

Name:

Email:

We respect your email privacy.