Create multiple headers in Wordpress

The Problem

As usual, a new problem arose when I was developing this site. I didn’t want the featured slider to appear on every page, as it was located in the header. You too, may want to display page-specific headers on your site. Well, it’s not that hard.

The Fix

First, open your header.php file and copy and paste its contents into a new file. Name this new file “headerwithnofeaturedslider.php” or whatever is more semantic to you. Make sure you remove the offending featured slider portion (or include/remove what you want from this version of the header). Save and upload this new header file to your site.

Now you have two headers; you could easily make another, and another, and so on. Next we need to call them to appear on the pages in Wordpress. In my case, I wanted to include the “headerwithfeaturedslider.php” only on my home page. Every other page would load the normal header. So in my index.php file I replace the normal header tag with to include the new header file we created, like so:

<?php include (TEMPLATEPATH . '/header_notebook.php'); ?>  

All other pages will load the regular header. As you can see, it’s very simple. The most involving part would be changing your headers.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Sphinn
  • Google
  • StumbleUpon
  • BlinkList
  • Design Float
  • Pownce
  • Slashdot
  • Technorati

4 Comments

  1. Rob
    Posted November 20, 2008 at 6:54 am | Permalink

    Hi Mike, I’m new to developing on wordpress and I’m currently developing a site that I need to be able to change the header file on every page(its not just reloading an image, im using a plugin to load in additional content) .
    (I’m not experienced in php) How can I get the different pages to call the different headers?
    ?

  2. admin
    Posted November 20, 2008 at 7:48 pm | Permalink

    Hi Rob,

    Can you duplicate the header files, and name give them names for each page, and then use the include path shown above to call each one on a particular page?

    If you link me to the problem I’ll take a look in case it’s more complicated than that.

    thanks

  3. Posted December 28, 2008 at 12:39 pm | Permalink

    Rob this worked great and is exactly what I was looking for. You’re a gentleman and a scholar!

    Thanks!

  4. Posted December 28, 2008 at 12:40 pm | Permalink

    Whoops, didn’t mean to call you the wrong name there Mike! Sorry!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*