October 5

Add multiple headers to your wordpress theme

0  comments

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.


Tags

headers, multiple, theme, wordpress


You may also like

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Get in touch

Name*
Email*
Message
0 of 350