Select Page

This tutorial assumes that you are using a standard installation of WordPress 3.3.1 with Twenty Eleven 1.3 theme by the WordPress team.

Recently one of my clients wanted to add the ability to define custom titles for each page on their site. This ability is not provided by default on a standard WP installation. The following instructions and script add that functionality to your WP installation:

    1. Login to WordPress Admin site and open the ‘Editor’ under ‘Appearance’ tab
    2. Open ‘Header.php’ file
    3. Browse the file till you see the starting tag for ‘<title>’
    4. Replace the test/code between the starting and closing tags of <title> with the following code:
      <?php
       global $post;
       $MyCustomTitle = get_post_meta($post->ID,"MyCustomTitle",true);
       if ($MyCustomTitle): echo "$MyCustomTitle";
       else: ?>
       <?php the_title();?>
       <?php endif; ?>
    5. Save (Update) the header.php file

This concludes your coding part of this effort to add custom titles to pages. Now using this new found function is quite easy.

For each page you would like to add custom title to, open the page for editing and scroll down to ‘Custom Fields’. If you don’t see custom fields, select to view the ‘Custom Fields’ option in the screen options.

Once in the custom fields section, add a new custom attribute named ‘MyCustomTitle’ [Yes. The same phrase we used on the code above] for the page. In the value section, type in your custom title for the page. I used “Awesome Siris Graphics!!!” as my example custom title.

customtitle-instruction