WordPress Tip: Insert Content automatically after each Post in wordpress

wordpress-logoWordPress is a great blogging platform which is highly configurable. It allows you a lot of things to do with your Blog. For example, notice the Share Buttons at the end of this post. User can click on those buttons and share this article in any of their favorite social site. If you have subscribe for RSS feed for this blog, you may notice the same buttons at the end of the article in your RSS Reader. So how to add content automatically after each Post? Simple, use WordPress Hooks to add Filters that add content. For example copy below code in functions.php file inside your theme folder.
function insertRSSFootNote($content) { if(!is_feed() && !is_home()) { $content.= "<div class='subscribe'>"; $content.= "<h4>Enjoyed this article?</h4>"; $content.= "<p>Subscribe to our <a href='https://www.viralpatel.net/feed'>RSS feed</a> and never miss a recipe!</p>"; $content.= "</div>"; } return $content; } add_filter ('the_content', 'insertRSSFootNote');
Code language: PHP (php)
The insertRSSFootNote() function in above code simply append any text in the $content variable. Then, our insertRSSFootNote() function is hooked to the the_content() function, and it is automatically called every time the the_content is called. Using this function is basically the same as typing in the text at the end of each post. Notice the (!is_feed) condition on line 2, which prevents the text from being inserted in the RSS feed. If you want the text to appear in your RSS feed, replace line 2 with the following:
if (!is_home()) {
Code language: PHP (php)
Simply modify the code and add text of your choice at the end of each post in WordPress. Happy Blogging…
Get our Articles via Email. Enter your email address.

You may also like...


  1. Merry says:

    Hi, I am using wordpress learning theme, I have added the code but it is not working :(. is there any alternate solution ? I want to add google adds after every post, waiting for good comments, thanks,

  2. Andreza says:


    I want to obtain a set of news from rss feeds and store them in the database.

    I`m using some feeds that do not provide images. So, I would like to know if this plugin allow users to get the images from the google images (or other source) automatically. The key words to search the images would be “Title” of the news.

    I want that all my posts (obtained from the feeds) have images to show in my listing.

    Thank you.

  3. Hey there!
    I noticed this post, and found it quite informative. Although the instructions do work, it can be a little risky to add code to your theme, as when it is updated that code will be lost. You could get around this by using a child theme, but I think I have an easier way :-).
    We at 2MB solutions have just released our first (totally free!) plugin, called 2MB Autocode. It allows you to place text at the top or bottom of each post, with an override on a per-post basis. It basically does what this is talking about, except without the theme overwriting it each update :-). You can find it here: http://wordpress.org/plugins/2mb-autocode/ or you can look at our website: http://2mb.solutions.
    Happy blogging!
    -Michael, 2MB Solutions.

Leave a Reply

Your email address will not be published. Required fields are marked *