CSS not applying to Sub category pages
-
Hi there
Can anyone help with this issue I have where the category specific Stylesheet does not get applied to a sub page which sits on a single.php
The dev site is here
I’m building a blog, shop and news page on a site which all run on the Posts of a wordpress install.
Each needs slightly different layout and styles/colours applied to it, hence the different stylesheets.
In the head I have:
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" /> <?php if ( is_category('news')) { ?> <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/styles/news.css" type="text/css" media="screen" /> <?php } ?> <?php if ( is_page('about')) { ?> <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/styles/about.css" type="text/css" media="screen" /> <?php } ?> <?php if ( is_category('people')) { ?> <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/styles/people.css" type="text/css" media="screen" /> <?php } ?> <?php if ( is_category('shop')) { ?> <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/styles/shop.css" type="text/css" media="screen" /> <?php } ?> <?php if ( is_page('submit')) { ?> <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/styles/submit.css" type="text/css" media="screen" /> <?php } ?> <?php if ( is_page('crits')) { ?> <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/styles/crits.css" type="text/css" media="screen" /> <?php } ?> <?php if ( is_category('blog')) { ?> <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/styles/blog.css" type="text/css" media="screen" /> <?php } ?> <?php if ( is_page('say-hi')) { ?> <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/styles/say-hi.css" type="text/css" media="screen" /> <?php } ?>
The individual category pages for each section need to be different and I pull the 3 different loops in as templates:
<?php $post = $wp_query->post; if ( is_category('3') ) { include(TEMPLATEPATH . '/loop-news.php'); } elseif ( is_category('5') ) { include(TEMPLATEPATH . '/loop-blog.php'); } elseif ( is_category('9') ) { include(TEMPLATEPATH . '/loop-shop.php'); } else { include(TEMPLATEPATH . '/loop-people.php'); } ?>
And then on single.php I use:
<?php $post = $wp_query->post; if ( in_category('3') ) { include(TEMPLATEPATH . '/single2.php'); } elseif ( in_category('5') ) { include(TEMPLATEPATH . '/single1.php'); } elseif ( in_category('9') ) { include(TEMPLATEPATH . '/single3.php'); } else { include(TEMPLATEPATH . '/single4.php'); } ?>
These styles apply perfectly to the category page for each, however if I drill down to a page that uses the single template it doesn’t apply the stylesheet.
I’m sure it was working before I started work on the ‘shop’ category and it was only after changing the statement to an ‘elseif’ statement from an ‘if else statement’ on single.php that I got issues.
Any help to my garbled message would be appreciated
Thanks in advance
John
- The topic ‘CSS not applying to Sub category pages’ is closed to new replies.