• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Gokul Deepak

Gokul Deepak

GoCool and Debug

  • Home
  • WordPress
  • Android
  • How to
  • About Me

How to Add WordPress Default Text in Post Editor

December 6, 2016 by Gokul Deepak S Leave a Comment

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

 

 

 

Filed Under: Wordpress

Authored by Gokul Deepak S

Leave a Reply Cancel reply

0 Comments
Inline Feedbacks
View all comments

Primary Sidebar

Popular Pages

  • How to find the date of the Facebook group it was created
  • How to add ads.txt on Bluehost
  • Elementor Plugin and Nginx Configuration
  • Home
  • CORS error in Apache Tomcat - Solved
  • Combine two separate files line by line in Notepad++

Archives

Categories

  • Android
  • Apache
  • AWS
  • Blogger
  • Computer Tips
  • DevOps
  • Docker
  • Earn
  • Facebook Tips
  • Git
  • Google Tips
  • Hosting
  • How to
  • Laptop Tips
  • Laptops
  • Linux
  • Mobile
  • MongoDB
  • Nginx
  • Node JS
  • Notepad++
  • PostgresQL
  • Ubuntu
  • Wordpress
  • Xenforo

Tags

Android Android One AWS Bluehost Comparisions Custom ROM Elementor Facebook Genesis Genesis Sample Theme Google Drive How to Lineage OS Notes OnePlus One OwnCloud Rooting Smartphones Stock ROM Studiopress Tomcat Wordpress plugin

Copyright © 2023 · Maintained by GokulDeepak

wpDiscuz