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.

15 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?

  4. jac00b says:

    Thank you so much!! This was extremely useful to me. There were other sites that recommended doing the same thing as you, but instead of using code after my_custom_text (your example: $my_custom_text = ‘

    In case of any ©Copyright issues please check CopyRights page for faster resolutions.

    ‘; //), they just wrote out your other example, which to me doesn’t work (your example: $my_custom_text = ‘Place the text you wish to insert before your post content here inside the single quotes only.’;).

    Using my_custom_text without using html code afterwards (in this case

    ) doesn’t work for me at all (it throws out a syntax error on that particular line, but when I put it in

    brackets it works perfectly), so thank you for using the example with html code as well (I didn’t even know I could insert the html code in this php script – obviously I have little to no experience with php).

    So for anyone that gets a syntax error without using html after my_custom_text, just use html code there and it should work great.

    Thanks again, 🙂
    J.

    • jac00b says:

      In my above comment the html code got deleted/integrated so it makes less sense, but in short, html code was needed to me (in this case the p, paragraph html) after the my_custom_text string in order to make the text appear at all

  5. Binosh says:

    Thank you

  6. Arsh says:

    Thanks.. Worked like charm.. 🙂

  7. Arslan says:

    It worked. Thank you 🙂

  8. nujra says:

    working but my slider went to bottom after adding this 🙁 please help me

  9. Blake Miller says:

    This is great! How do you exclude additional post types. Some 3rd party plugins and/or themes create custom post types, such as FAQs, Portfolios, or in one of my cases, a Team Bio / Directory listing plugin which is now displaying the custom text which not only do I not need, looks a little goofy.

  10. Thanks. A simple and elegant solution. If we ever meet, I owe you a beer.

  11. Ariel says:

    Thanks for the clean code. But the text appears after the post title and image. Is there a way to display this text before the post’s title? Thanks much appreciated

  12. thebusinessentourage says:

    This is great! How would I make the words a link for users to click on. I’ve tried this but i get an error that link is expired. Any idea on how to fix this?

Leave a Reply

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