Skip to content Skip to sidebar Skip to footer

Add multiple headers to your wordpress theme

By default, to include the wordpress header in all of your files you use this function:

[php]

<?php get_header();  ?>

[/php]

What this function does, it looks for the file called header.php inside the root folder of your theme.

But there comes a time when you need to add more than one header to your theme. This could be for many reasons, such as:

  • You want to use a different header for another page
  • You want to add another menu to that specific header
  • You need a different header structure for another page
  • and so on….

Anyway, it is real simple to add as many headers as you can using the following code snippet:

[php]

<?php
get_header(‘your_header’);
//replace your_header with your desired name(s)
?>

[/php]

Just like above, the function will now look for the file called header-your_header.php inside your theme root folder. This code can be used in any page/template you desire. Also you can add as many headers you desire inside your theme.

What's your reaction?
0Smile0Lol0Wow0Love0Sad0Angry

Leave a comment