How to Create Replacement Page Titles in WordPress

Here’s a quick tutorial showing how to replace your Page titles in WordPress with custom values different to those shown in your site’s navigation. Sorry about the poor sound quality — I wasn’t speaking from inside a cave, I just had the wrong levels set for my microphone!

In case you can’t make out the code that’s being written in the screencast, you can copy and paste from below…

In header.php, replace your <title> tag with this:

<?php $rpt = get_post_meta($post->ID, 'Replacement_Page_Title', true); ?>
<title>
<?php if ($rpt) { echo $rpt . " &laquo; "; }
else { wp_title('&laquo;', true, 'right'); }; ?> <?php bloginfo('name'); ?></title>

In page.php, replace your Page Title code with this:

<?php $rpt = get_post_meta($post->ID, 'Replacement_Page_Title', true); ?>
<h2><?php if ($rpt) { echo $rpt; } else { the_title(); }; ?></h2>

About RobBarrett

Rob is the graphic and web designer behind Rob Barrett Design and Nice Hot Cuppa. You can follow him on Twitter: @robbarrett
This entry was posted in tutorial, wordpress and tagged , , . Bookmark the permalink. Follow any comments here with the RSS feed for this post. Both comments and trackbacks are currently closed.

One Response to How to Create Replacement Page Titles in WordPress

  1. ali says:

    this is good, l like it bec very clear and easy to follow