Hook pre create Post

Is there one way to hook when someone enters on “Create Post Page” (Not update post page) and pre-fill title and body fields?

Something like:

Read More
add_filter( 'WP_FILTER_ENTERS_CREATE_POST_PAGE', 'my_function_callback' )

function my_function_callback() {

    # dummy title
    $title     = 'My Post Tile';

    # dummy post content
    $post_body = '<p>Hi it is post body</p>';

    # set editor content
    wp_editor( $postBody, 'my_editor_id'); // not sure

    # set post title
    ???????

}

Thanks in advance!:)

Related posts

1 comment

  1. After a search in Codex https://codex.wordpress.org/Plugin_API/Filter_Reference i found “default_content” and “default_title” filters that are exactly that i looking for!

    # filter content
    add_filter( 'default_content', 'default_editor_content', 10, 2 );
    
    # filter content function callback
    function default_editor_content( $content, $post ){
        $content = "<p><strong>Heloo!!</strong> I am custom content</p>";
    
        return $content;
    }
    
    # filter title
    add_filter( 'default_title', 'default_title_value', 10, 2 );
    
    # filter title function callback
    function default_title_value( $title, $post ){
        $title = "Custom post Title here";
    
        return $title;
    }
    

    after this… when open wp-admin/post-new.php the title input field and editor content appears filled with default values.

Comments are closed.