WordPress get_header() : How to create and get a second header.php

WordPress is soo flexible when it comes to customizing your website or theme. The header.php file in the WordPress Theme allows you to add menu and logo to all the pages on your site, as well are do many more.

You can create as many header.php files are you want and use theme anywhere in your website.

Here are 3 steps on how to create and get your custom header.php file using get_header();

STEP 1

Make a copy of your default header.php so for instance, the new copy will be header-two.php

This should contain all the codes from your header.php

STEP 2

Edit your new header-two.php file.

While you edit, remember to maintain everything in the
<head> </head>
section especially the
 <?php wp_head(); ?>
and also remember to keep the opening <body> section  do check from your footer.php to make sure you are not deleting any other div section that starts in the header

STEP 3

If you are creating a custom page template, you can go ahead and replace the default
get_header();
with
get_header('two');

Remember to change name ‘two’ to any name u may have used for your second header.php copy.

You can also use on post views, category, archive and single post view. Just apply the if statement and the name or id of the category, archive or single post you want to use your header-two.php on

<?php
if ( is_category() ) : // if ( is_category(10) ) the 10 being the category id
get_header( 'two' ); // get header-two.php
elseif ( is_archive() ) :
get_header( 'three' ); // get header-three.php
elseif ( is_single() ) :
get_header( 'four' ); // get header-four.php
else :
get_header(); // else the default header.php
endif;
?>

You can create as many header files are as you want by following the above steps.

Download:   6 Best WordPress Blog Themes

Good Luck and leave comments below or Click Here to visit the support forum

Posted On March 18, 2017