Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Create a new 'simple' post
- $postID = $wp->newPostEz('Simple Post Title', 'Simple Post Text');// And get the Post basic informations
- $post = $wp->getPostEz($postID);?>
- The advanced post creation method
- <?php
- // Let's create a Post ... the advanced way
- $newPost = new elWpNewPost('post');$newPost->set( 'Advanced Title', // Post title
- 'Advanced Text', // Post text
- 'Advanced More', // Optional more text
- 'Advanced Excerpt' // Optional excerpt
- );// Posts with a future date change status to future by themselves
- $newPost->set_status('publish');// Set post slug: nice permalink thingy
- $newPost->set_slug('post-slug');// Create categories before assigning them
- $wp->newCategories(array('Category3', 'Category4'));// Add categories next
- $newPost->add_categories('Category3', 'Category4');// Add post tags
- $newPost->add_keywords('tag1', 'tag2');// Add custom fields
- $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
- $newPost->enable(true, true);// Scheduled 1 Day from now ;) ... use 0 for current time
- $newPost->set_time(time() + (24 * 3600));// Create the Post and get the ID
- $postIDEx = $wp->newPostEx($newPost->as_array());// And get the Post complete informations
- $postEx = (array)$wp->getPostObj($postIDEx);?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement