Automatically insert content after each post
Automatically insert content after each post
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.= “
“; $content.= “
Enjoyed this article?
“; $content.= “
Subscribe to our RSS feed and never miss a recipe!
“; $content.= “
“;
}
return $content;
}
add_filter (‘the_content’, ‘insertFootNote’);