functions2.php

<?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

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.