Advertisement
Guest User

wp_insert_post code

a guest
Jan 23rd, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. $new_post = array(
  2. 'post_title' => $title,
  3. 'post_content' => $story,
  4. 'post_category' => array('12'), // Usable for custom taxonomies too
  5. 'tags_input' => array($tags),
  6. 'post_status' => 'submission-received', // Choose: publish, preview, future, draft, etc.
  7. 'post_type' => 'post' //'post',page' or use a custom post type if you want to
  8. );
  9. //save the new post
  10. $pid = wp_insert_post($new_post);
  11.  
  12. /* Insert Form data into Custom Fields */
  13. add_post_meta($pid, 'form-name', $name, true);
  14. add_post_meta($pid, 'form-email', $email, true);
  15. add_post_meta($pid, 'form-city', $city, true);
  16. add_post_meta($pid, 'form-state', $state, true);
  17. add_post_meta($pid, 'form-agree', $agree, true);
  18.  
  19. print '<pre>';
  20. var_dump(array($new_post, $pid));
  21. print '</pre>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement