How to Add WordPress Default Text in Post Editor

December 6, 2016

Gokul Deepak S

If you are up to enter same text repeatedly in the post you may automize it. Simply add wordpress default text in Post editor so that when you are up to add a new post the default content will be there already and so you can edit it or add some other text to it.

Add the following code in functions.php

 

add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
  $content = "Write Anything here. Ithu Chumma Trailer thaan ma.";
  return $content;
}

 

 

The above code will work for all post types. Whether Custom Post type or Post or Page It would show the same text for every one. If you want different text for different contents use the below code.

add_filter( 'default_content', 'default_content', 10, 2 );

function default_content( $content, $post ) {

    switch( $post->post_type ) {
        case 'post':
            $content = 'Default Text For Post';
        break;
        case 'page':
            $content = 'Default Text For Post';
        break;
        case 'Movie':
            $content = 'Default text for Movie';
        break;
        default:
            $content = 'Default Text for Other Post Types';
        break;
    }

    return $content;
}

 

 

 

About the author

Gokul Deepak is a DevOps engineer focused on building reliable cloud systems through automation, observability, and disciplined infrastructure design. He shares practical insights from real-world production environments, helping engineers build systems that scale with clarity and confidence.

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments