How To Use Multiple Stylesheet In WordPress

Posted by

Hi,

In many cases we require to design two stylesheet according the web browser such as IE Stylesheet and general stylesheet. In order to use second stylesheet that can be used for certain pages you need to edit the header.php file of your theme and locate your existing stylesheet code:

<link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen” />

Now, you need to make an adjustment so that it will only show the code in a certain situation. For example, if you want a certain category to use a different stylesheet, you need use the following code:

<?php if ( is_category(‘1’) ) {
<link rel=”stylesheet” href=”<?php bloginfo(‘template_url’); ?>/cat-alt.css”
type=”text/css” media=”screen” />;
<?php } else { ?>
<link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>”
type=”text/css” media=”screen” />
<?php } ?>

You are assigning the cat-alt.css to be used for category 1. Every other page will use the normal stylesheet.

That’s it!

Thanks,

Shane G.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.