Skip to main content

when the category comes from a form, how I can use in wp_insert_post?

$my_post = array(); $my_post['post_author'] = $userid; $my_post['post_title'] = $name; $my_post['post_name'] = str_replace(' ', '-', $name); $my_post['post_category'] = $selected = $_POST['postcats']; $newpost_id= wp_insert_post( $my_post );

$my_post = array(); 
$my_post['post_author'] = $userid; 
$my_post['post_title'] = $name; 
$my_post['post_name'] = str_replace(' ', '-', $name); 
$my_post['post_category'] = $selected = $_POST['postcats']; 
$newpost_id= wp_insert_post( $my_post );

is it correct? what is it wrong? thanks a lot

when the category comes from a form, how I can use in wp_insert_post?

$my_post = array(); $my_post['post_author'] = $userid; $my_post['post_title'] = $name; $my_post['post_name'] = str_replace(' ', '-', $name); $my_post['post_category'] = $selected = $_POST['postcats']; $newpost_id= wp_insert_post( $my_post );

is it correct? what is it wrong? thanks a lot

when the category comes from a form, how I can use in wp_insert_post?

$my_post = array(); 
$my_post['post_author'] = $userid; 
$my_post['post_title'] = $name; 
$my_post['post_name'] = str_replace(' ', '-', $name); 
$my_post['post_category'] = $selected = $_POST['postcats']; 
$newpost_id= wp_insert_post( $my_post );

is it correct? what is it wrong? thanks a lot

Source Link

insert category from form in a post

when the category comes from a form, how I can use in wp_insert_post?

$my_post = array(); $my_post['post_author'] = $userid; $my_post['post_title'] = $name; $my_post['post_name'] = str_replace(' ', '-', $name); $my_post['post_category'] = $selected = $_POST['postcats']; $newpost_id= wp_insert_post( $my_post );

is it correct? what is it wrong? thanks a lot