|
|
View previous topic
::
View next topic
|
Author |
Message |
ramon fincken Site's programmer
 Get a free globally recognized avatar It's free!
Joined: 03 Aug 2007 Posts: 412 Location: A'dam/Diemen, The Netherlands
|
Posted: Mon Sep 28, 2009 8:45 pm Post subject: [wordpress][solution] How to code (API) a new post or page insert .. |
|
|
How to write your own code to insert a post or a page? Eazy! just use wp_insert_post()
Here you go:
http://codex.wordpress.org/Function_Ref...nsert_post
Warning: do not use $my_post['post_author'] = 1; as stated on the codex page, use 2 for the main admin.
Code: | // Create post object
$my_post = array();
$my_post['post_title'] = 'My post';
$my_post['post_content'] = 'This is my post.';
$my_post['post_status'] = 'publish';
$my_post['post_author'] = 2;
$my_post['post_category'] = array(8,39);
// Insert the post into the database
wp_insert_post( $my_post );
|
Code: | $defaults = array(
'post_status' => 'draft',
'post_type' => 'post',
'post_author' => $user_ID,
'ping_status' => get_option('default_ping_status'),
'post_parent' => 0,
'menu_order' => 0,
'to_ping' => '',
'pinged' => '',
'post_password' => '',
'guid' => '',
'post_content_filtered' => '',
'post_excerpt' => ''
);
|
|
|
Back to top |
|
 |
Google adsense Advertisement
|
Posted: Mon Sep 28, 2009 8:45 pm Post subject: [wordpress][solution] How to code (API) a new post or page insert .. |
|
|
Advertisement
|
|
Back to top |
|
 |
GravityForms Advertisement
|
Posted: Mon Sep 28, 2009 8:45 pm Post subject: [wordpress][solution] How to code (API) a new post or page insert .. |
|
|
Advertisement
 |
|
Back to top |
|
 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|