Family Encyclopedia >> Electronics

How to Add Default Content to the WordPress Post Editor

As a seasoned WordPress developer with extensive experience customizing sites for clients, I've noticed many users repeatedly add the same call-to-action text to every post—such as prompts to subscribe to their feed, retweet, or share on Facebook. Rather than typing it manually each time, you can set it as the default content directly in the WordPress post editor.

To implement this, open your active theme's functions.php file and add the following code within the PHP tags:

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

That's all! Create a new post, and your default content will appear pre-filled in the editor.

Update (January 24, 2013) – A user asked how to set different default content for various post types. Use this enhanced code to customize it for specific custom post types:

add_filter( 'default_content', 'my_editor_content', 10, 2 );
function my_editor_content( $content, $post ) {
    switch ( $post->post_type ) {
        case 'sources':
            $content = 'Your sources content here.';
            break;
        case 'historias':
            $content = 'Your historias content here.';
            break;
        case 'fotos':
            $content = 'Your fotos content here.';
            break;
        default:
            $content = 'Your default content here.';
            break;
    }
    return $content;
}

Source: Justin Tadlock