Add Text To Bottom Of Every Post in WordPress

Content Management Systems

Maintaining and upgrading a website sometimes becomes a headache when you have to remember all the custom changes done till date. So to avoid this situation I usually create a ‘how to article’ on the same so that in case of any theme changes, all my custom changes can be traced back & reapplied. Similarly in this article we will explain a quick method to add text to bottom of every post in WordPress. For example here we added a copyright text below to every post.

In my scenario I had to add a copyright disclaimer text to the end of each post for easy reference by someone. If you are looking to add some other text with html content also it works just fine. To achieve the same we have to follow below steps:

1. Login to your WordPress site wp-admin console.
2. Navigate to Appearance>Editor

wordpress add text to bottom of every post
3. Search for Theme Functions (functions.php) file and click on it to start the edit.
Note: It is wise to take a backup of existing working functions.php before editing to revert back in case of any issues.
4. Add below given code to the end of the Theme Functions (functions.php) file.

Code to add text after every post content:

add_filter('the_content','add_my_content');
function add_my_content($content) {
$my_custom_text = '<p><font size="2">In case of any ©Copyright issues please check <a href="http://www.techpaste.com/disclaimer/">CopyRights</a> page for faster resolutions.</font></p>'; //
if(is_single() && !is_home()) {
$content .= $my_custom_text;
}
return $content;
}

Bonus Code to add text before every post content:

add_filter('the_content','add_my_content');
function add_my_content($content) {
$my_custom_text = 'Place the text you wish to insert before your post content here inside the single quotes only.';
if(is_single() && !is_home()) {
$content = $my_custom_text.$content;
}
return $content;
}

Sample Screenshot:

wordpress add text to bottom of every post

5. Click on Update file to get the code change take effect.
6. If you have caching plugins installed then delete the cache to see the changes take effect.

Check out end of this posts content you will be able to see the inserted text via code. If you like the post then please like and share the same.

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

4 Responses

  1. Peter says:

    What if I want that text to be bold? Thank you.

  2. Binosh says:

    Thank you. Very useful for me

  3. ireneciser says:

    How can this be made to work on pages instead of, or in addition to posts?

Leave a Reply