Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Input data
- $my_page = array();
- $my_page["post_title"] = $alternatename_main;
- $my_page["post_content"] = $postcontent;
- $my_page["post_excerpt"] = $postexcerpt;
- $my_page["post_status"] = "publish";
- $my_page["post_date"] = date("Y-m-d H:i:s");
- $my_page["post_author"] = 1;
- $my_page['post_type'] = 'post';
- $my_page["post_name"] = "test1234";
- // Local insert
- $my_page_id = wp_insert_post($my_page);
- $wp_post_data = get_post($my_page_id);
- $wp_guid = $wp_post_data->guid;
- // Insert XML-RPC
- include_once( ABSPATH . WPINC . '/class-IXR.php' );
- include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' );
- $client = new WP_HTTP_IXR_Client('http://test/site/xmlrpc.php');
- $client -> debug = true; //optional but useful
- $username = "yyyyyy";
- $password = "xxxxxx";
- $params = array(0,$username,$password,$my_page);
- $clientresult = $client->query('wp.newPost', $params);
- $my_page_id = $client->getResponse();
- $wp_guid = get_the_guid($my_page_id);
- $wp_post_data = get_post($my_page_id);
- $wp_slug = $wp_post_data->post_name;
- $my_page_update = array();
- $my_page_update["guid"] = "http://test/site/".$wp_slug."/";
- $params = array(0,$username,$password,$my_page_id,$my_page_update);
- $clientresult = $client->query('wp.editPost', $params);
- UPDATE wp_posts SET guid='"http://test/site/".$wp_slug."/"' WHERE ID=".$my_page_id .";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement