WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] conditional header graphic on main blog page (7 posts)

  1. Jonas Grumby
    Member
    Posted 4 years ago #

    Hi all. I'm trying to have a unique header graphic on the main blog page of a site. The name of the page is blog and it is not the home page. Using if (is_page( 'blog' )) doesn't work. Can someone point out the correct way to identify this page in a conditional tag?

    Thanks

  2. haydenhancock
    Member
    Posted 4 years ago #

    I would make sure you have permalinks enabled. I don't think it will pick up the page unless you've actually enabled permalinks and set the specific page to be "blog". Your code is correct though...

    <?php if (is_page('blog')) { ?>
    do something
    <?php } else { ?>
    do something else
    <?php } ?>
  3. esmi
    Forum Moderator
    Posted 4 years ago #

    No - the conditional is incorrect. Try:

    <?php if (is_home() ) { ?>
    do something
    <?php } else { ?>
    do something else
    <?php } ?>

    http://codex.wordpress.org/Conditional_Tags#The_Main_Page

  4. Jonas Grumby
    Member
    Posted 4 years ago #

    Thanks Esmi. That works. I would have expected that to cause the graphic on the home page to change.

  5. haydenhancock
    Member
    Posted 4 years ago #

    Oh sorry, I thought he was trying to specify a particular page other than the home page. I must have misread the original post.

  6. esmi
    Forum Moderator
    Posted 4 years ago #

    is_home() tests for the main posts page. If you have a static front page, then this will be the page you selected for Posts in settings/Reading.

    is_front_page() test for the front (home) page.

  7. Jonas Grumby
    Member
    Posted 4 years ago #

    I have it thanks. I read the doc.

Topic Closed

This topic has been closed to new replies.

About this Topic