daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest Sep 22nd, 2016 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Input data
  2. $my_page = array();
  3. $my_page["post_title"] = $alternatename_main;
  4. $my_page["post_content"] = $postcontent;
  5. $my_page["post_excerpt"] = $postexcerpt;
  6. $my_page["post_status"] = "publish";
  7. $my_page["post_date"] = date("Y-m-d H:i:s");
  8. $my_page["post_author"] = 1;
  9. $my_page['post_type'] = 'post';
  10. $my_page["post_name"] = "test1234";
  11.  
  12. // Local insert
  13. $my_page_id = wp_insert_post($my_page);
  14. $wp_post_data = get_post($my_page_id);
  15. $wp_guid = $wp_post_data->guid;
  16.    
  17. // Insert XML-RPC
  18. include_once( ABSPATH . WPINC . '/class-IXR.php' );
  19. include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' );
  20.  
  21. $client = new WP_HTTP_IXR_Client('http://test/site/xmlrpc.php');
  22.  
  23. $client -> debug = true; //optional but useful
  24.  
  25. $username = "yyyyyy";
  26. $password = "xxxxxx";
  27. $params = array(0,$username,$password,$my_page);
  28.  
  29. $clientresult = $client->query('wp.newPost', $params);
  30.  
  31. $my_page_id = $client->getResponse();
  32.  
  33. $wp_guid = get_the_guid($my_page_id);
  34.    
  35. $wp_post_data = get_post($my_page_id);
  36. $wp_slug = $wp_post_data->post_name;
  37.  
  38. $my_page_update = array();
  39. $my_page_update["guid"] = "http://test/site/".$wp_slug."/";
  40. $params = array(0,$username,$password,$my_page_id,$my_page_update);
  41. $clientresult = $client->query('wp.editPost', $params);
  42.    
  43. UPDATE wp_posts SET guid='"http://test/site/".$wp_slug."/"' WHERE ID=".$my_page_id .";
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top