Style depending on Category
-
Hey Folks,
a short introduction:
I am running the current version of WordPress (3.4.2) with the new TwentyTwelve Theme (version 0.9, release should be around next week).
I made some modifications to the theme (yes I made a childtheme) and almost everything is working as I want it.
I modified the header.php and inserted a if..else to check for the category. Depending on the category a different header image and css is loaded.This works almost perfectly fine, however:
On my mainpage it uses the category of the last post of the page (bottom), not the first. How can I change it that it uses the first post in the loop and not the last?
Here is the code for the stylesheets in the <head>:
<?php wp_head(); ?> <?php if (in_category('banana') ): ?> <link rel="stylesheet" href="<?php bloginfo( 'stylesheet_directory' ); ?>/banana.css" type="text/css" media="screen" /> <?php elseif (in_category('strawberry') ): ?> <link rel="stylesheet" href="<?php bloginfo( 'stylesheet_directory' ); ?>/strawberry.css" type="text/css" media="screen" /> <?php endif; ?>
Here the code for the header:
<?php if (in_category('banana') ): ?> <img src="<?php bloginfo( 'stylesheet_directory' ); ?>/headers/banana.png" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /> <?php elseif (in_category('strawberry') ): ?> <img src="<?php bloginfo( 'stylesheet_directory' ); ?>/headers/strawberry.png" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /> <?php else: ?> <img src="<?php bloginfo( 'stylesheet_directory' ); ?>/headers/header.png" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /> <?php endif; ?>
and here the link to the blog, you can see the effect in action if you go to the second page:
https://www.balluff-transnational.eu
thank you very much
- The topic ‘Style depending on Category’ is closed to new replies.