How to Add Default Content in Your WordPress Post Editor


Have you ever find yourself entering the same text in all of your posts? Often people do that such as asking people to subscribe to their feeds, retweet the post, share it on facebook etc. You can always use a simple tag to add it right after the content, or you can add that text as the default content in your WordPress post editor.

Simply open up your WordPress theme’s functions.php file and paste the following code within the PHP tags ofcourse.

add_filter( 'default_content', 'my_editor_content' );  function my_editor_content( $content ) {  	$content = "If you like this post, then please consider retweeting it or sharing it on Facebook.";  	return $content;  }

And you are done. Try to create a New Post, and you should see the new content there.

Update (January 24, 2013) – One of our users asked us how to add different content for different post type in the comments. The code below will show you how to add different default content in your WordPress post editor for each specific custom post type:

  add_filter( 'default_content', 'my_editor_content', 10, 2 );    function my_editor_content( $content, $post ) {        switch( $post->post_type ) {          case 'sources':              $content = 'your content';          break;          case 'stories':              $content = 'your content';          break;          case 'pictures':              $content = 'your content';          break;          default:              $content = 'your default content';          break;      }        return $content;  }  

Source: Justin Tadlock

Seraphinite AcceleratorOptimized by Seraphinite Accelerator
Turns on site high speed to be attractive for people and search engines.