wp_insert_post fails within wp-admin
-
Hello – I have a wordpress problem I am trying to figure out; trying to create a wp-admin script that creates a new wp post…
here is the code:
$my_post = array(
‘post_title’ => ‘My post Gman99’,
‘post_content’ => ‘This is my post.’,
‘post_status’ => ‘draft’,
‘post_author’ => 1,
‘post_category’ => array(8,39)
);$post_id = wp_insert_post( $my_post );
echo $post_id;And let me stress that this code works fine if I run it on a “front end” page; i just put the code in short code using “short code exec php” plugin and it creates the post no problem and spits out the post id; but when I try to do the same from within wp-admin it fails? dos anyone have any idea why this would be occurring?
thanks, G
- The topic ‘wp_insert_post fails within wp-admin’ is closed to new replies.