• Is is possible to have 2 header files? The one on my homepage will be different from the others and I can’t find another solution than 2 headers unless I move the navigation and logo code in each page and use different styles for the homepage template.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Copy your page.php file, and where it says <?php get_header(); ?>, replace that with your modified header.php file. Then insert the following at the top:

    <?php
    /* Template Name: Home Page */
    ?>

    Thread Starter nemci7v

    (@nemci7v)

    Thanks for the solutions! Adding another header file should be easy but I’d like to learn how to use hooks ??

    Is body.home the frontpage or just a page named home?

    Thread Starter nemci7v

    (@nemci7v)

    Hmmm I don’t understand the technique.

    What I’m trying to do is change the font colors of nav links and replace the header background just on the frontpage.

    I have in my CSS

    #home_header (for the homepage)

    and

    #header (for regular pages)

    and they each have their own list and font styling. So following the technique I don’t understand is how to call #home_header properties on the frontpage.

    Do I add
    <body <?php if (function_exists('body_class')) body_class(); ?>>

    and replace “body_class” with #home_header?

    sorry.. I never used hooks before.

    Try adding <body <?php if (function_exists('body_class')) body_class(); ?>> to your header.php and then check the source code of a couple of page types (single posts, categories, Pages) to see the list of available body classes. There’s a full list of the potential classes that will be generated by WP on the page I linked to above.

    Thread Starter nemci7v

    (@nemci7v)

    Hmm nothing appears. I think I’m not ready for hooks lol.

    Thread Starter nemci7v

    (@nemci7v)

    Sorry for posting so much.. I can’t yet translate what I want in php but is there a code like “if home – load home_navigation.php, else just use the default div classes in header” ? or default_navigation.php

    Thread Starter nemci7v

    (@nemci7v)

    Thanks! I was looking at that and came up with..

    if (is_front_page() || is_single()) {
       <?php include (TEMPLATEPATH . '/nav_homepage.php'); ?>
    }
    else {
       the default code here
    }

    I haven’t tested the code yet but do you think it’s correct? ??

    Thread Starter nemci7v

    (@nemci7v)

    Ok I got it!! For anyone else trying to achive this use,

    <?php if (is_front_page()) { ?>
    homepage stuff
    <?php } else {?>
    other stuff
    <?php } ?>
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘2 header.php on 1 site’ is closed to new replies.