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.


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;
}

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

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

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;
}




Related Post


Latest Post


Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.