TopSeoTutWordpressHow to Add Custom Text Before and After Post Title

How to Add Custom Text Before and After Post Title

Add Custom Text Before and After Post Title
Add Custom Text Before and After Post Title

WordPress is huge website management and development platform (CMS – Content Management System). It has incredible and powerful features that built your site exactly as you wish.

One of the interesting tricks in wordpress, is displaying custom text or a keyword automatically before or after all old and new posts. It’s very helpful when you have a certain or main keyword and you would like to make it appear in all posts automatically.

How to Display Custom Text or a Keyword Before and After Post Title?

The php file responsible of modifying the posts title, is not located in your wordpress theme editor as usual – but its located in wp-includes/post-template.php. So, you have to access your website’s files through FTP client or cPanel interface to be able to edit this file.

cpanel

Before we go ahead, you have to take backup of “post-template.php” file – Just in case you messed something and prevent breaking your site. Open “post-template.php” file in txt editor or code editor in cPanel and find this line

function the_title($before = '', $after = '', $echo = true)

post_template

Explanation of the_title Parameters:

$before: Write here the text that you would like to place it before the title.
$after: type here the text that you would like to display it after the title.
$echo: Don’t change this parameter, leave it as it “true” – because it display the title in your theme, but if you would like to remove or hide your post’s title then make it “false

Example of Displaying Custom Text Before and After Post Title

Let’s make it real, i will add “How to” before the title – and – “Tutorials” after the title. Check the following images for the simple instruction.
Hint: You should add one space before and after your text words to prevent adhesion your text with the main title.
post_title_example

results

results2

Best SEO Practices

  • Don’t overused.
  • Don’t use irrelevant keywords to attract the visitors attention.
  • Don’t use words like (visit us, click here, etc) to spam Google spiders.
  • Don’t use very rich long tails keywords because it will make your title too long.

Did you find this trick useful to you, then why not share it with others. If you have any suggestions or questions, just write them down in a small comment below.

RELATED ARTICLES
Most Popular

Recent Comments