How To Publish A WordPress Custom Post Type Post Programmatically

Which native method I can use to publish the WordPress custom post type post programmatically

You can use wp_insert_post to insert and publish the WordPress custom post type post programmatically

$post_id = wp_insert_post(array (
    'post_type' => 'post_type',
    'post_title' => $title,
    'post_content' => $content,
    'post_status' => 'publish',
    'comment_status' => 'closed',  
    'ping_status' => 'closed',  
));
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments