How to Add WordPress Default Text in Post Editor

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

 

 

 

Gokul Deepak S

Recent Posts

Running crontab on AWS auto scaling group

Linux has a convenient feature of running cronjob which will get executed at the correct…

11 months ago

Learn with Gokul

As famous Tamil poet Auvaiyar said "Katradhu Kai Mann Alavu, Kallathathu Ulaga Alavu" which is…

11 months ago

Terraform Cheat sheet

Terraform Cheatsheet with pdf. You can download Terraform Cheatsheet pdf with all Terraform CLI commands…

11 months ago

Strategy to prepare for Terraform Associate Exam Preparation

I was planning to do Terraform certification a long time ago. I have worked on…

11 months ago

Runcloud vs SiteGround Comparision

As a user of both of these services has got multiple benefits with both of…

2 years ago

Important Docker Commands to remember

You need not memorize these important docker commands. Repeated usage will make it easy for…

2 years ago

This website uses cookies.