Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Create a new 'simple' post
  3. $postID = $wp->newPostEz('Simple Post Title', 'Simple Post Text');// And get the Post basic informations
  4. $post = $wp->getPostEz($postID);?>
  5. The advanced post creation method
  6. <?php
  7. // Let's create a Post ... the advanced way
  8. $newPost = new elWpNewPost('post');$newPost->set(        'Advanced Title', // Post title
  9.        'Advanced Text', // Post text
  10.        'Advanced More', // Optional more text
  11.        'Advanced Excerpt' // Optional excerpt
  12. );// Posts with a future date change status to future by themselves
  13. $newPost->set_status('publish');// Set post slug: nice permalink thingy
  14. $newPost->set_slug('post-slug');// Create categories before assigning them
  15. $wp->newCategories(array('Category3', 'Category4'));// Add categories next
  16. $newPost->add_categories('Category3', 'Category4');// Add post tags
  17. $newPost->add_keywords('tag1', 'tag2');// Add custom fields
  18. $newPost->add_custom_field('cf', 'value1');$newPost->add_custom_field('cf', 'value2');$newPost->add_custom_field('cf1', 'value11');$newPost->add_custom_field('cf2', 'value22');// Enable both comments and pings
  19. $newPost->enable(true, true);// Scheduled 1 Day from now ;) ... use 0 for current time
  20. $newPost->set_time(time() + (24 * 3600));// Create the Post and get the ID
  21. $postIDEx = $wp->newPostEx($newPost->as_array());// And get the Post complete informations
  22. $postEx = (array)$wp->getPostObj($postIDEx);?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement