Posted By

stephcode on 09/30/10


Tagged

header headers wordpress multiple


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tmbrenneke


Use multiple custom headers on a WordPress theme


 / Published in: PHP
 

URL: http://www.wprecipes.com/how-to-use-multiple-custom-headers-on-a-wordpress-theme

The first thing to do is to create header files. Create as many different headers as you want. In this exemple, I have created 3 custom headers from my theme default file header.php, names headercontact.php, headergallery.php and headerdefault.php.

By using the php include() function and WordPress conditional tags, we can define custom headers easily. Replace the content of your header.php file with the following code:

  1. <?php
  2. if (is_page('contact')){
  3. <?php include(TEMPLATEPATH.'/headercontact.php'); ?>
  4. }
  5. elseif (is_page('gallery')){
  6. <?php include(TEMPLATEPATH.'/headergallery.php'); ?>
  7. }
  8. else {
  9. <?php include(TEMPLATEPATH.'/headerdefault.php'); ?>
  10. }
  11. ?>

Report this snippet  

You need to login to post a comment.