Ready to get started?Download WordPress


[resolved] How do I change the header on one page only? (7 posts)

  1. haiiro
    Posted 2 years ago #

    Howdy! This seemed like it would be easy, but I've tried a variety of code snippets from these forums without any luck.

    My site is set up to display a static front page, with the blog portion appearing on /blog. I want the blog to have a different header, and I've been trying to accomplish this with PHP and the is_page function.

    Here's my latest non-working iteration:

    <?php if(is_page('Blog')){
    echo 'BLOG HEADER';}
    echo 'MAIN HEADER';}?>

    I'm no PHP expert (nor a WP expert!), so I don't know how else to skin this cat. Thanks in advance for any help you can provide!

    EDIT: Forgot to add that BLOG HEADER and MAIN HEADER are, of course, the location of the appropriate header images.

  2. Andrew
    Forum Moderator
    Posted 2 years ago #

    Try this function in-place of page_is

  3. haiiro
    Posted 2 years ago #

    I caught my typo and edited it; I've been using is_page without success.

  4. Andrew
    Forum Moderator
    Posted 2 years ago #

    If you have a specific template assigned to your page, you could try;

    if ( is_page_template( 'templateFileName.php' )
  5. haiiro
    Posted 2 years ago #

    Okay, page templates look promising. From reading the codex, it doesn't even sound like I'd need any special code -- just create a page template for /blog, apply it, and have the only difference be the header. I'll give that a shot. Thanks!

  6. haiiro
    Posted 2 years ago #

    Hmm. The page template for my theme calls the header.php file...which won't be different no mater what page template I use. Is there another option here?

  7. haiiro
    Posted 2 years ago #

    A friend slung me this altered version, which works like a charm:

    <?php if (is_page()) echo 'MAIN HEADER';
    else echo 'BLOG HEADER';?>

Topic Closed

This topic has been closed to new replies.

About this Topic