category / child category conditional
-
I am designing my category.php file. I would like to link to different CSS files depending on what category the post is assigned to. Basically, if a post if from category 1 or a child category of 1 I would like to link to cat1.css and if the post is from category 2 (or child category of 2) I would want to link cat2.css
Below is my code from category-header.php Unfortunately it is not working, it doesn’t display the child categories.
<?php if ( is_category(1) ) { echo '<link rel="stylesheet" href="' . get_bloginfo(template_directory) . '/style/css/cat1.css" type="text/css" media="screen" />'; } else { echo '<link rel="stylesheet" href="' . get_bloginfo(template_directory) . '/style/css/cat2.css" type="text/css" media="screen" />'; }
Any help is much appreciated!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘category / child category conditional’ is closed to new replies.