different headers for different pages within wordpress

  • Appnonymous
  • Born
  • Born
  • Appnonymous
  • Posts: 3

Post 3+ Months Ago

Hi

I am trying to have a different header for each page within my wordpress site. I have tried follwing various wordpress tutorials without success. i get mid way through then either the page stops working or the php i have implemented goes squiffy.

simply put i want the home page to have an image carousel fading in and out. while the other pages have a static image

i tried using this

PHP Code: [ Select ]
<?php
if (is_page('2')) { //home page
include(TEMPLATEPATH.'/header.php');
} elseif (is_page('19')) {
include(TEMPLATEPATH.'/header-tariff.php.');
} elseif (is_page('21')) {
include(TEMPLATEPATH.'/header-bookings.php.');
} elseif (is_page('23')) {
include(TEMPLATEPATH.'/header-directions.php.');
} elseif (is_page('25')) {
include(TEMPLATEPATH.'/header-contactus.php.');
} elseif (is_page('27')) {
include(TEMPLATEPATH.'/header-eveningmeals.php.');
} else {
include(TEMPLATEPATH.'/header.php');
}
?>
 
  1. <?php
  2. if (is_page('2')) { //home page
  3. include(TEMPLATEPATH.'/header.php');
  4. } elseif (is_page('19')) {
  5. include(TEMPLATEPATH.'/header-tariff.php.');
  6. } elseif (is_page('21')) {
  7. include(TEMPLATEPATH.'/header-bookings.php.');
  8. } elseif (is_page('23')) {
  9. include(TEMPLATEPATH.'/header-directions.php.');
  10. } elseif (is_page('25')) {
  11. include(TEMPLATEPATH.'/header-contactus.php.');
  12. } elseif (is_page('27')) {
  13. include(TEMPLATEPATH.'/header-eveningmeals.php.');
  14. } else {
  15. include(TEMPLATEPATH.'/header.php');
  16. }
  17. ?>
  18.  


but it just makes my page hang indefinitely.

i have my header.php with this sample code (i will change the line that has the image for a carousel)
PHP Code: [ Select ]
<body <?php body_class(); ?>>
 
<div id="art-main">
<div style="width: 950px; margin: auto; height: 350px;">Still Banner Image 1</div>
    <div class="art-sheet clearfix">
<nav class="art-nav">
    <?php
   echo theme_get_menu(array(
         'source' => theme_get_option('theme_menu_source'),
         'depth' => theme_get_option('theme_menu_depth'),
         'menu' => 'primary-menu',
         'class' => 'art-hmenu'
      )
   );
   get_sidebar('nav');
?>
    </nav>
<div class="art-layout-wrapper">
                <div class="art-content-layout">
                    <div class="art-content-layout-row">
                        <div class="art-layout-cell art-content">
 
  1. <body <?php body_class(); ?>>
  2.  
  3. <div id="art-main">
  4. <div style="width: 950px; margin: auto; height: 350px;">Still Banner Image 1</div>
  5.     <div class="art-sheet clearfix">
  6. <nav class="art-nav">
  7.     <?php
  8.    echo theme_get_menu(array(
  9.          'source' => theme_get_option('theme_menu_source'),
  10.          'depth' => theme_get_option('theme_menu_depth'),
  11.          'menu' => 'primary-menu',
  12.          'class' => 'art-hmenu'
  13.       )
  14.    );
  15.    get_sidebar('nav');
  16. ?>
  17.     </nav>
  18. <div class="art-layout-wrapper">
  19.                 <div class="art-content-layout">
  20.                     <div class="art-content-layout-row">
  21.                         <div class="art-layout-cell art-content">
  22.  

and then this code for header-tariff.php
PHP Code: [ Select ]
<body <?php body_class(); ?>>
 
<div id="art-main">
<div style="width: 950px; margin: auto; height: 250px;">Tariff banner 250</div>
    <div class="art-sheet clearfix">
<nav class="art-nav">
    <?php
   echo theme_get_menu(array(
         'source' => theme_get_option('theme_menu_source'),
         'depth' => theme_get_option('theme_menu_depth'),
         'menu' => 'primary-menu',
         'class' => 'art-hmenu'
      )
   );
   get_sidebar('nav');
?>
    </nav>
<div class="art-layout-wrapper">
                <div class="art-content-layout">
                    <div class="art-content-layout-row">
                        <div class="art-layout-cell art-content">
 
  1. <body <?php body_class(); ?>>
  2.  
  3. <div id="art-main">
  4. <div style="width: 950px; margin: auto; height: 250px;">Tariff banner 250</div>
  5.     <div class="art-sheet clearfix">
  6. <nav class="art-nav">
  7.     <?php
  8.    echo theme_get_menu(array(
  9.          'source' => theme_get_option('theme_menu_source'),
  10.          'depth' => theme_get_option('theme_menu_depth'),
  11.          'menu' => 'primary-menu',
  12.          'class' => 'art-hmenu'
  13.       )
  14.    );
  15.    get_sidebar('nav');
  16. ?>
  17.     </nav>
  18. <div class="art-layout-wrapper">
  19.                 <div class="art-content-layout">
  20.                     <div class="art-content-layout-row">
  21.                         <div class="art-layout-cell art-content">
  22.  


how do i implement these header files? which file to i place the code on (header.php?)

Your help is much appreciated
  • Appnonymous
  • Born
  • Born
  • Appnonymous
  • Posts: 3

Post 3+ Months Ago

i have progressed a little but now what is happening is when i click on TARIFF i get the change in depth as shown on the 2 different header php files but now i am getting part of the home page on the tariff page
Attachments:
Tarrif.png
  • Appnonymous
  • Born
  • Born
  • Appnonymous
  • Posts: 3

Post 3+ Months Ago

i changed the code to be
PHP Code: [ Select ]
<?php
if ( is_home() ) :
   get_header( 'home' );
elseif ( is_page('tariff') ) :
   get_header( 'tarrif' );
else :
   get_header();
endif;
?>
 
  1. <?php
  2. if ( is_home() ) :
  3.    get_header( 'home' );
  4. elseif ( is_page('tariff') ) :
  5.    get_header( 'tarrif' );
  6. else :
  7.    get_header();
  8. endif;
  9. ?>
  10.  

but i am still getting the same outcome, homepage is fine but the tariffs page has the homepage within it
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 483

Post 3+ Months Ago

have you tried to echo out each area that fires to see what might be going on?

Like
PHP Code: [ Select ]
<?php
if(is_home()) {
   
   echo 'in if<br />';
   get_header('home');
 
} else if (is_page('tariff')) {
   
   echo 'in else if<br />';
   get_header('tarrif');
 
} else {
   
   echo 'in else<br />';
   get_header();
 
}
?>
 
  1. <?php
  2. if(is_home()) {
  3.    
  4.    echo 'in if<br />';
  5.    get_header('home');
  6.  
  7. } else if (is_page('tariff')) {
  8.    
  9.    echo 'in else if<br />';
  10.    get_header('tarrif');
  11.  
  12. } else {
  13.    
  14.    echo 'in else<br />';
  15.    get_header();
  16.  
  17. }
  18. ?>
  19.  

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 12 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.