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

For some reason, you may want to be able to automatically display a custom text below each of your posts. You can hard-code it, but it will be way better to do so using a WordPress hook. Here’s how to do.

You just have to paste the following code into your functions.php and save the file. Once done, custom content will be inserted below each of your posts.

function add_post_content($content) {
	if(!is_feed() && !is_home()) {
		$content .= '<p>This article is copyright &copy; '.date('Y').'&nbsp;'.bloginfo('name').'</p>';
	}
	return $content;
}
add_filter('the_content', 'add_post_content');

Thanks to Jeff Starr for the great snippet!

By the way, if you need any kind of WordPress help I’m happy to inform you that I’m starting to work freelance. Don’t hesitate to contact me to get a quote for your new project!

Tags

10 Comments

  1. Wow, works perfectly, just what i needed, thanks a lot!!

  2. It works perfectly, but it also is adding the content to pages, not just posts. Is there a simple way to restrict this ONLY to posts?

  3. Worked perfect, much better than hard coding content in

  4. Very useful tip.
    It’s work well. Thanks for sharing 🙂

  5. I was looking for some auto fill jQuery plugins but after reaching this site I have found a lots of plugin, I would like to appreciate the admin, and also request for keep upload such useful materials. Thank you 🙂

  6. I’m beginning to dabble in wp plugin development. This code definitely is a keeper for me. But isn’t there a hook or placeholder or something that points to the end of the post’s content so that I would not need to process the whole content anymore before adding my text?

  7. I want to put it after post but it appears after related post widget see here the screenshot http://prntscr.com/1ijv67 there is a huge list of plugins that do this but i need to put after the post not after related post widget i have used some plugins but all in vain. Please tell me what i want thank you

  8. This coding will help to add before the post content, but not after. The below link may useful to add new information before or after or both on the content area.

    http://buffercode.com/method-add-new-content-post-area-wordpress/

  9. This is useful! Any idea how to insert custom content after the nth post? Like an ad after the third post in an archive?

Leave a Comment

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