I would like to have one specific page on my WordPress blog omit the header .

Is there a way to wrap that title code from page.php in my WordPress theme in an if clause that specifies the page I do not want the title to appear on? For instance, if page is 135, do not display title, else display.



Sure, if you want it by ID (which might or might not be good idea, depending on how likely ID will stay same for a long time - no migrations, etc) that would be something like:

if( !is_page(135) ) {

    //  code goes here

See Conditional Tags > Page in Codex for more.

Alternative way would be to do this in some filter, as opposed to editing template files.

  • Great! Thanks so much. How would a filter work? – macreator Jun 22 '11 at 20:54
  • @macreator that would entirely depend on what and how much you want to hide (single function with filter available - easy, multiple function or without handy filters - hard). – Rarst Jun 22 '11 at 21:03
  • Got it. I think I'll stick with the conditional tag above. One question I have though is how can I put the title code within the tag? What I have so far is: <?php if( !is_page(135) ) { echo"<h2 class='posttitle'><?php the_title(); ?></h2>"; }?> But for obvious reasons the php title code doesn't work when encapsulated in php code. – macreator Jun 22 '11 at 21:18
  • @macreator your syntax there makes no sense in PHP - even if you are echoing HTML you are still in PHP context there, should be something around echo "<h2 class='posttitle'>"; the_title(); echo "</h2>"; – Rarst Jun 22 '11 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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