BlogTutorials

How to Add Default Content in Your WordPress Post Editor

Have you ever ever end up coming into the identical textual content in all your posts? Usually individuals do this akin to asking individuals to subscribe to their feeds, retweet the publish, share it on fb and so forth. You may at all times use a easy tag so as to add it proper after the content material, or you may add that textual content because the default content material in your WordPress publish editor.

Merely open up your WordPress theme’s capabilities.php file and paste the next code throughout the PHP tags ofcourse.

1
2
3
4
5
add_filter( 'default_content', 'my_editor_content' );
operate my_editor_content( $content material ) {
    $content material = "If you happen to like this publish, then please take into account retweeting it or sharing it on Fb.";
    return $content material;
}

And you might be executed. Attempt to create a New Put up, and you need to see the brand new content material there.

Replace (January 24, 2013) – One in every of our customers requested us the right way to add completely different content material for various publish sort within the feedback. The code beneath will present you the right way to add completely different default content material in your WordPress publish editor for every particular customized publish sort:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
add_filter( 'default_content', 'my_editor_content', 10, 2 );
operate my_editor_content( $content material, $publish ) {
    swap( $publish->post_type ) {
        case 'sources':
            $content material = 'your content material';
        break;
        case 'tales':
            $content material = 'your content material';
        break;
        case 'photos':
            $content material = 'your content material';
        break;
        default:
            $content material = 'your default content material';
        break;
    }
    return $content material;
}

Download The WPSaviour App Now

Related posts
Best WordPress PluginsBlog

How to Add Google Fonts in WordPress Post Editor

Best WordPress PluginsBlog

How to Add Content Templates in WordPress Post Editor

BlogTutorials

How to Add Custom Styles to WordPress Visual Editor

Beginner’s GuideBlog

14 Tips for Mastering the WordPress Visual Editor

Leave a Reply

Your email address will not be published.

Pay in your preferred currency
Indian rupee
Euro