WordPress: Category Styles

After changing the wordpress template files used to generate the layout for the Kit-Cars and Rock Climbing categories, I’ve taken the additional step of updating the new templates to use new CSS (cascading style sheet) files. The idea is that the style and layout will now vary depending on the current category.
The wordpress template file (e.g. category-1.php) defines things like the background images, what content is placed on the screen and where it will be placed.
The CSS file defines more specifics such as font sizes, text colour and borders. All these things can be changed individually in the layout file but the CSS defines the defaults.
In order to add a custom CSS file (e.g. category-1.css) to your custom template file) e.g. category-1.php, find the following code fragment in the template

<style type="text/css" media="screen">
@import url<?php bloginfo('stylesheet_url'); ?> );
</style>

and change it to

<style type="text/css" media="screen">
@import url(<?php bloginfo('stylesheet_directory'); ?>/category-1.css );
</style>

Of course this is just an example based on my site. What you need to do may vary, but I hope this makes a good starting point.

This entry was posted in Internet. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>