Insert new custom post type in wordpress.
// Create post object
$my_post = array(
'post_title' => wp_strip_all_tags( $_POST['post_title'] ),
'post_content' => $_POST['post_content'],
'post_status' => 'publish',
'post_type' => 'my_custom_post',
'post_author' => get_current_user_id()
);
// Insert the post into the database
wp_insert_post( $my_post );
// Create post object
$my_post = array(
'post_title' => wp_strip_all_tags( $_POST['post_title'] ),
'post_content' => $_POST['post_content'],
'post_status' => 'publish',
'post_type' => 'my_custom_post',
'post_author' => get_current_user_id()
);
// Insert the post into the database
wp_insert_post( $my_post );
No comments:
Post a Comment