Search Polybore

Monday, January 23, 2012

How to hide/ remove page titles/ headers: WordPress 2011 Theme

Ok so you have set up your pages on the WordPress 2011 theme but you do not want that big page title displaying at the top of each page.

The good news is it is very easy to do. Hopefully you have found this article before wading through the WordPress forums wasting time and being thoroughly bamboozled.

Anyway, moan over, here is how we worked out how to do it ourselves and which we wish we had just done in the first place…

To do this we are going to comment out the section where the script calls for and displays the title of a page. This will effect all of the pages you have set up and all subsequent pages you create ie the title will no longer display on the page but happily will still appear in your menus. It is just a wee modification so no need to worry about causing major damage here. First off we need the editor and the relevant template…

Dashboard/ Appearance/ Editor/ Templates/ content-page.php

Modify the script so that it looks like this.



 * The template used for displaying page content in page.php


 * @package WordPress

 * @subpackage Twenty_Eleven

 * @since Twenty Eleven 1.0





<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    <header class="entry-header">

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

    </header><!-- .entry-header -->



    <div class="entry-content">

        <?php the_content(); ?>

        <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?>

    </div><!-- .entry-content -->

    <footer class="entry-meta">

        <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>

    </footer><!-- .entry-meta -->

</article><!-- #post-<?php the_ID(); ?> -->

All we have done is commented out the section of code that deals with the header by open multiline comment /* close multiline comment */, just like the creator of this template has commented out the template info at the very top.

Easy to reverse this by deleting the comment script if we decide we want the titles back.

Don’t forget to click “Update File”. That is it. Have a look at your pages and you will see the titles/ headers have gone.

Bear in mind that if, or more likely when, the WordPress (twenty eleven) 2011 Theme updates your changes will be lost so it is worth creating a child theme. Here is how to do that

No comments:

Post a Comment