WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For the purpose of good HTML structure, accessibility and SEO I'd like to change the site's title and description from H1 and H2 to P when appearing on any page other than the homepage. A conditional statement logic would be something like; when not homepage change site title and description to Site Title and Description

. Thanks!

share|improve this question
up vote 1 down vote accepted
<?php if (is_home() || is_front_page()) { $header_tag = 'h1'; }
    else { $header_tag = 'h2'; } ?>

<<?php echo $header_tag;?>><?php the_title();?></<?php echo $header_tag; ?>>

Expanding on what Stephen Harris said, here is a useable example. Lots of different ways to use same code function.

share|improve this answer
Perfectly simple. I'm using a page as my homepage so this is closer to what I need. Thanks! – whatsthebigidea Apr 18 '12 at 23:35
the same principle is used in the default theme Twenty Ten - it might be useful to look through the code of the default themes to learn a few tricks. – Michael Apr 18 '12 at 23:48

There are two conditionals, depending on your setup:

  • is_home() - checks if the main page is being displayed
  • is_front_page() - returns TRUE when the main blog page is being displayed and the Settings->Reading->Front page displays is set to "Your latest posts", or when is set to "A static page" and the "Front Page" value is the current Page being displayed.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.