2 Steps to Add Default Content in WordPress Post Editor for Different Post Types – WordPress Tips

By | April 19, 2019

We can add different default content in wordpress post editor for different post types, in this tutorial, we will introduce you how to add with some little code in functions.php, you can do by following our steps.

Here are steps:

Step 1. Open your theme functions.php file

Step 2. Paste and edit code below

add_filter( 'default_content', 'my_editor_content', 10, 2 ); 
function my_editor_content( $content, $post ) {
    switch( $post->post_type ) {
    // set default content by 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;
}
 

Leave a Reply

Your email address will not be published. Required fields are marked *