Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

Thanks!

share|improve this question
add comment

1 Answer

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.

share|improve this answer
    
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
    
Perfect. Thanks! –  macreator Jun 22 '11 at 21:31
add comment

Your Answer

 
discard

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.