-1

i've spent way too much time trying to use the wp_insert_post() function a <form> and i do not know why it is not working.

// Create post object
  $my_post = array(
     'post_title' => 'My post',
     'post_content' => 'This is my post.',
     'post_status' => 'publish',
     'post_author' => 1,
     'post_category' => array(8,39)
  );

// Insert the post into the database
  wp_insert_post( $my_post );

I'm probably doing something wrong.

If possible can you please hook this to a form. Thanks verymuch. I just need an example to see what i am doing wrong.

here is a link to where i previously asked. pls don't mark dupe.

1 Answer 1

3
// Create post object
$my_post = array();
$my_post['post_title']    = 'My post';
$my_post['post_content']  = 'This is my post.';
$my_post['post_status']   = 'publish';
$my_post['post_author']   = 1;
$my_post['post_category'] = array(0);
// Insert the post into the database
wp_insert_post( $my_post );"

This works fine. You code is correct, but it is an problem in the form to send the $_POST data? See on this post for feature informations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.