Default or Preset Content for Custom Post Types

Use the second parameter $post and check $post->post_type alongside a switch, it’s easier and nicer to work with than several if else if else, etc..

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

function my_editor_content( $content, $post ) {

    switch( $post->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;
}

Hope that helps..

Leave a Comment