How To Allow Title Overwrite On WordPress Blog?

Posted by

Hi,

The the_title(); function is used to display the title of a post or page. But You may need to overwrite this function and use a custom title. In order to do that, paste this code in single.php and page.php where you want the post/page title to be displayed.

<?php $title = get_post_meta($post->ID, “custom-title”, true);
if ($title != “”) {
echo “<h1>”.$title.”</h1>”;
} else { ?>
<h1><?php the_title(); ?></h1>
<?php } ?>

When you have added and save on server you have to create a custom field named custom-title and type your custom title as a value.

That’s it!

Thanks,

Shane G.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.