WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] How do I change the header on one page only?

[Resolved] How do I change the header on one page only?

  • haiiro
    Member

    @haiiro

    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';}
    else{
    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Andrew Nevins
    Forum moderator

    @anevins

    Try this function in-place of page_is
    http://codex.wordpress.org/Function_Reference/is_page

    haiiro
    Member

    @haiiro

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

    Andrew Nevins
    Forum moderator

    @anevins

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

    if ( is_page_template( 'templateFileName.php' )

    haiiro
    Member

    @haiiro

    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!

    haiiro
    Member

    @haiiro

    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?

    haiiro
    Member

    @haiiro

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

    <?php if (is_page()) echo 'MAIN HEADER';
    else echo 'BLOG HEADER';?>
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] How do I change the header on one page only?’ is closed to new replies.