DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Most blogs automatically displays some text after each post, for exemple to ask readers to subscribe to their rss feed. This text is very often hardcoded. Why not using function.php instead, and be able to keep the text when you’ll switch theme?

To achieve this recipe, simply paste the following code in your functions.php file. By using functions.php, you’ll not have to re-insert this code if you switch themes.

function insertFootNote($content) {
        if(!is_feed() && !is_home()) {
                $content.= "<div class='subscribe'>";
                $content.= "<h4>Enjoyed this article?</h4>";
                $content.= "<p>Subscribe to our  <a href='http://feeds2.feedburner.com/WpRecipes'>RSS feed</a> and never miss a recipe!</p>";
                $content.= "</div>";
        return $content;
add_filter ('the_content', 'insertFootNote');

Credits goes to Cédric Bousmane for that trick!

One Comment

  1. Where in the functions file? I inserted it at the very bottom and it crashed the site until I removed it.

Leave a Comment

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