different header.php files for different categories
-
Hi everyone,
have a question how to implement different headers for different categories?
Right now I have the following (I have created 4 php files for headers and added this lines to the archives.php, single.php, index.php):
<?php
if (in_category(‘3’)) {
include (‘header-hopes.php’);
}
elseif (in_category(‘2’)) {
include (‘header-memories.php’);
}
elseif (in_category(‘4’)) {
include (‘header-dreams.php’);
}
else {
include (‘header.php’);
}
?>
but this doesn’t work, I have only header.php included everywhere. Have no clue why as I’m not good in php.
I need only this 3 to be different. The function is_category or the method of creating special category-2 or sth do not work as I need EVERYTHING that is assigned to the category (including single posts and lots of subcategories in it) to have a certain header and style.css that is written there.Any ideas how to do this?
PS. I noticed strange thing in my code, it depends on the order:
– so if I put memories at the first position only this header is used for all
– if I put dreams as the first and memories as the last, memories works for memories and dreams works for dreams and hopes
– if I put hopes as the first and memories as the last, memories works for memories and hopes works for dreams and hopes
so everything that goes at the first position is used for all except memories
The topic ‘different header.php files for different categories’ is closed to new replies.