Forums

Is multi headers possible in one blog? (4 posts)

  1. hits502
    Member
    Posted 3 years ago #

    Hello:
    I'm building a site that has 3 distinct pages and I'd like them to have their own headers. For example, my dog page will have a header with dog images, cat page with cat images, etc. Is this possible? Whether yes or no, can you please tell me how to go about it?

    Thanks in advance!
    Henry

  2. 11worth
    Member
    Posted 3 years ago #

    Hi,

    Yes, you can do it. You create additional header.php files to match specific page templates.

    For example:
    You already have a default template; you can make that your dog page, that uses by default header.php with the include tag, <?php get_header(); ?>. header.php has the dog stuff in it.

    Create a new header file and call it header2.php. This is the same as header.php, but has the cat stuff in it.

    For the second page, the cat page, create a new page template and call it cat.php. This could be simply a duplicate of the default template, but with the include tag <?php include (TEMPLATEPATH . '/header2.php'); ?> instead of <?php get_header(); ?>. This ensures that the cat header is matched with the cat page.

    You can create additional pages, by naming new header files (header3.php, and so forth), and naming page templates that have matching include tags.

    Hope this works for you.

  3. 11worth
    Member
    Posted 3 years ago #

    Something more to add...in case you're not familiar with creating new page templates, here's the basics:

    • Copy your page.php file, and rename it to your new template name, in this case cat.php
    • At the top of cat.php, add this code, directly above the header include tag:
      <?php
      /*
      Template Name: Cat Page
      */
      ?>

      And obviously, you would use your new header include tag, <?php include (TEMPLATEPATH . '/header2.php'); ?>

    • When you create your page in Admin/Pages/Add New Page, select the Cat Page as the page template in the Template drop-down in the right column. Header 2 should be displayed on the page.
  4. davethepak
    Member
    Posted 3 years ago #

    This is some great advice for complete custom control.

    However, if you are ok with the same header structure, but just want different IMAGES, then you can put some php in the header which changes the background images based on the page.

    I have seen a few themes that do this.

    ~ DPAK

Topic Closed

This topic has been closed to new replies.

About this Topic