WordPress.org

Ready to get started?Download WordPress

Forums

Different Headers for each 'page' (6 posts)

  1. monkeypup
    Member
    Posted 8 years ago #

    Hey guys.. Seems I can't go a day without asking for help on the support forum..
    Really, It's not like I don't try looking for the answers in the codex and the forum before I ask.
    Sigh....
    Anyway, I'd really like to have a different header image for each of my 'pages', while still keeping everything else the same as the main theme. Do I really need to create a php template file for each page? If so, what would be the best way to simply use the existing theme yet call a different header (or a different style sheet, which could call the different header)?
    Thanks everyone! The wordpress support forums rock for someone like me who is still learning how to do everything. It's things like this that make me love wordpress so much.
    Monkeypup
    http://www.monkeypup.org

  2. Lorelle
    Member
    Posted 8 years ago #

    Okay, let me just understand and clear up some jargon. I assume you are talking about Pages and not posts, right?

    Yes, you can create a specific template file for each version of the Page you want to use, which actually isn't very difficult. It's explained in the Codex Pages. Just copy the page.php with names like page-1.php, page-2.php or use the Page ID numbers to help you remember like page-42.php. Inside of page-42.php you would just change the header from this:

    include(get_template_directory() . '/header.php');

    to:

    include(get_template_directory() . '/header2.php');

    and have a different header image, text or whatever in header2.php.

    You could also use Conditional Tags and set up the INCLUDE header tag in a conditional tag using the is_page('42') where "42" is the page ID and put this on your page.php template file that says something like, if this is page 42, show header-42.php, and so on.

    You can find more about headers at Designing Headers.

  3. monkeypup
    Member
    Posted 8 years ago #

    Awesome, Thanks! after a while, I stopped checking in on this post after no response, but this seems to be what I want. You rock! WordPress rocks! It all rocks!

  4. monkeypup
    Member
    Posted 8 years ago #

    Wahoooo! I had to play around a lot (I am a coding idiot!) on my local server, but I figured it out. I think the fact that I was using K2 was an issue (I think the structure is different than usual), but this is what I did

    <?php if (is_home()) get_header(); ?>
    <?php if (is_page(24)) include(get_template_directory() . '/header2.php'); ?>

    and so on, at the top of the index. Worked like a charm. Not to design some page headers.....

  5. Lorelle
    Member
    Posted 8 years ago #

    Awesome.

    When the Codex comes back online, we might have to add this excellent example!!!

  6. kiko73
    Member
    Posted 8 years ago #

    hi everybody
    I have used the conditional tags for my pages and they works fine...till i realized that wordpress (for no reasons at all) duplicate the default header at the bottom of the page!

    this is the code for my page.php:

    <?php
    if (is_page('4'))
    {
    include(get_template_directory() . '/header-verifica.php');
    } else if (is_page('2'))
    {
    include(get_template_directory() . '/header-contatti.php');
    }
    else if (is_page('29'))
    {
    include(get_template_directory() . '/header-opensource.php');
    }
    else {
    include(get_template_directory() . '/header.php');
    }
    ?>

    You can see what happens to my pages here http://www.openwebitalia.it

    Thanks in advance to all

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.