Automatically insert content after each wordpress post

April 7, 2009 · Print This Article

Most wordpress blogs automatically displays some text after each post, for exemple to ask readers to subscribe to their rss feed of the blog. This text is very often hardcoded.

Fortunately, we can using function.php instead, and be able to manage all in one place when  you’ll switch theme.

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');


Your choice for site templates and wordpress themes

Comments

Got something to say?

You must be logged in to post a comment.