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







If you want to automatically add specific default or pre-defined content to your editor while publishing posts or pages, then insert one of the following codes into functions.php:
1)
function add_before_content($content) {
if ( ‘page’ == $post->post_type ) return $content .’Default page content.’;
if ( ‘post’ == $post->post_type ) return $content .’Default post content.’;
}
add_filter(‘the_content’, add_before_content);
2)
function add_before_content($content) {
return ‘Default Message’.$content;
}
add_action(‘publish_post’,add_before_content);
add_action(‘update_post’,add_before_content);
add_filter(‘the_content’, add_before_content);
What if I only want to add default content for certain post types?
Just updated the article for you with the way to do that
How do you add a recurring http:// url using this method, when i do the http:// starts commenting the code out
Hi — this is perfect. But need one tweak. How can this be applied to one type of post only or even to a certain post?
I’m not well-versed in php but tried the following:
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; }
function my_editor_content( $content ) {
if ( is_page( ‘about’ )) {
$content = “This is some custom content I’m adding to the post editor because I hate re-typing it.”;
return $content;
}
}
I don’t get an error. It simply doesn’t work. Is there a way to apply such a conditional to the function? Or, does a function do its thing with no respect to conditions?
Thanks — Mike
I have several blogs I want to try this code on. Thanks for sharing.
Wow, very interesting. Thanks for this post
Added code snippet to my notes really helpful.
Aren’t “Article Template Plugins” more useful?
For instance: http://wordpress.org/extend/plugins/article-templates/
Thanks! So simple but useful!