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.

So I have a static paged website and I want to make pages without title, but I still need the titles for the navigation to pick it up. How can I get rid of the Page.php (the_post()) from displaying the page title?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Somewhere in your page.php template will be a tag containing the_title(), and that's what you have to delete. In my Wordpress theme, for example, the code looks like this:

<?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>

    <div class="entry">
        <div <?php post_class(); ?>>
            <div class="post-meta">
                <h1><?php the_title(); ?></h1>

That last line is the one you need to get rid of. You can simply delete it and the post title will be removed from all Pages.

Note: If you have a theme like Twenty Eleven that does not contain the <?php the_title(); ?> tag inside page.php, you'll have to follow the clues from page.php to find out where the template is coming from. In the case of Twenty Eleven, page.php simply contains

<?php the_post(); ?>

<?php get_template_part( 'content', 'page' ); ?>

and no template tags at all. The clue is the get_template_part(): that tells us that page.php is pulling from a file called content-page.php. Look in the Twenty Eleven folder and you'll find content-page.php there for your editing pleasure. And sure enough, it contains this line:

<h1 class="entry-title"><?php the_title(); ?></h1>

Delete that and you're good to go.

share|improve this answer
    
haha thanks! Why would they split that little code into 2 files that's just over complicated IMO. –  Howdy_McGee Sep 20 '11 at 21:45
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.