Advertisement
Guest User

Untitled

a guest
Apr 8th, 2017
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: API Page
  4. */
  5.  
  6. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  7. $title = $_POST['title'];
  8. $content = $_POST['content'];
  9. $pub_time = $_POST['publish_time'];
  10.  
  11. $postdate = date($pub_time);
  12. $postdate_gmt = date($pub_time);
  13. $post = array(
  14. 'post_title' => ucfirst($title),
  15. 'post_name' => strtolower(sanitize_title($title)),
  16. 'post_content' => $content,
  17. 'post_status' => 'future',
  18. 'post_type' => 'post',
  19. 'post_author' => '1',
  20. 'post_date_gmt' => $postdate_gmt,
  21. 'post_date' => $postdate,
  22. );
  23.  
  24. wp_insert_post($post);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement