wp_insert_post not replicating standard admin 'new post' behaviour
I’m trying to implement some code using Advanced custom fields, to post rich posts (as in, with custom fields) from the front end. To add the new post, the code I have uses:
// Create a new post $post = array( // 'post_status' => 'draft' , 'post_title' => $_POST["post_title"], 'post_content' => $_POST["post_content"], 'post_type' => 'post' , 'post_status' => 'publish', ); // insert the post $post_id = wp_insert_post( $post ); // update $_POST['return'] $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );
I’ve noticed however, that this only creates a single/the ‘original’ post entry into the posts database table. In contrast, when I post the same post type from the wp-admin backend, a new post will enter not only the ‘original’ post into the database, but also seems to immediately create a revision entry also. The effect of this seems to be that if I update one of my frontend posts, the first incarnation is lost as the ‘original’ post is updated to match the latest revision, whereas in the wp-admin post, the originally created revision will still hold the very first incarnation of the post.
So, how can I replicate that behaviour on my front-end form?
- The topic ‘wp_insert_post not replicating standard admin 'new post' behaviour’ is closed to new replies.