Last active
December 31, 2015 01:19
-
-
Save andornagy/7913201 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_my_header() { | |
// if is home, which is the front page | |
if(is_home()) { | |
// then get the header-home.php | |
get_header('home'); | |
// else get the normal header.php | |
} else { | |
get_header(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_my_header() { | |
if( !is_home() ) { | |
global $post; | |
// get category by ID | |
$category = get_the_category($post->ID); | |
// first category slug | |
$catslug = $category[0]->slug; | |
// is there is a category slug call the header-$catslug.pgp | |
if (isset($catslug)) { | |
get_header($catslug); | |
} else { | |
// else call normal header.php | |
get_header(); | |
}// ends !is_home() | |
// else call normal header | |
} else { | |
get_header(); | |
}// ends isset() | |
} // ends get_myheader function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment