• I’ve created a child theme for Twenty Eleven and started my WP hacking journey.

    My question for the WP.org forum folk is whether or not it is possible to have a specific page or post I’ve created display an alternate header than the one displayed on the front page. My gut instinct is this would have something to do with templates, but I’m not quite sure.

    A simple example would be that on the front page of my blog the header displays the sub heading of the blog on the front page eg “This is a WP blog” while on the ABOUT ME page it displays just the title of the blog without the sub heading.

    Note: I’m not talking about changing the image in the header, I know you can do that and there are plugins for the functionality.

Viewing 1 replies (of 1 total)
  • Thread Starter j.biddy

    (@jbiddy)

    So after a lot of searching through the WP Codex here is the solution I was able to come up with.

    My first step was to log into my web server via FTP and download the template file I was using, in my case sidebar-page.php. Then I opened the file in a text editor (Bluefish) and changed the first part from this:

    <?php
    /**
    * Template Name: Sidebar Template
    * Description: A Page Template that adds a sidebar to pages
    *
    * @package WordPress
    * @subpackage Twenty_Eleven
    * @since Twenty Eleven 1.0
    */

    get_header(); ?>

    To this:

    <?php
    /**
    * Template Name: Sidebar Test Template
    * Description: A Page Template that adds a sidebar to pages
    *
    * @package WordPress
    * @subpackage Twenty_Eleven
    * @since Twenty Eleven 1.0
    */

    if ( is_page(‘whatever_page_you_want’)) :
    get_header( ‘whatever_page_you_want’ );
    else :
    get_header();
    endif;
    ?>

    whatever_page_you_want can be a page id eg 158, it can be an about page eg about.php. The next step is to create the header file that you want the get_header(); function to call. So, create the file header-whatever_page_you_want.php. Alter the layout of the header as you desire and upload the files to your child directory. To add more pages to have separate headers for:

    if ( is_page(‘whatever_page_you_want’)) :
    get_header( ‘whatever_page_you_want’ );
    elseif ( is_404() ) :
    get_header( ‘404’ );

    else :
    get_header();
    endif;
    ?>

    This worked for me and hopefully is considered best practices.

Viewing 1 replies (of 1 total)
  • The topic ‘Are multiple headers possible?’ is closed to new replies.