in WordPress

Add Custom Content After All Wordpress Posts

Content

There may be a time when you want to display a message at the end of all your posts on your wordpress blog. This can be for any promotional messages or to even add your social bookmarking content. In this article I will quickly show you a small snippet to add content after each post.

Add Content After All Posts

Using the Wordpress add filters you can apply a function to display the content. All you have to do is copy the following code into your functions.php page and content will automatically be added to the end of your content on all posts. This will check that the post is not on an RSS feed and that the current page is not the home page and then it will add the following to the content of the post.

function add_after_post_content($content) {
    if(!is_feed() && !is_home() && is_singular() && is_main_query()) {
        $content .= '<p>Content that is added after the post content.</p>';
    }
    return $content;
}
add_filter('the_content', 'add_after_post_content');

Subscribe To The Weekly Newsletter

Get weekly updates to your email