Advertisement
janter13

WP XMLRPC MASS EDIT

Jan 7th, 2017
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <?php
  2.  
  3. function api($rpc, $method, $filter=null){
  4.     global $USERNAME, $PASSWORD;
  5. $status = $rpc->query($method, "1", $USERNAME, $PASSWORD, $filter);
  6. if(!$status){
  7.     print "Error (".$rpc->getErrorCode()."):";
  8.     print $rpc->getErrorMessage()."\n";
  9.     exit;
  10. }
  11.  
  12. $comment = $rpc->getResponse();
  13.     return $comment;
  14. }
  15.  
  16. /*
  17. * https://codex.wordpress.org/XML-RPC_WordPress_API/Posts
  18. * http://scripts.incutio.com/xmlrpc/
  19. */
  20.  
  21. $USERNAME = "USERNAME_WP";
  22. $PASSWORD = "PASS_WP";
  23. $xmlrpc_path = "http://nama.tld/xmlrpc.php";
  24. require "IXR_Library.php";
  25. $rpc = new IXR_Client($xmlrpc_path);
  26.     $list_id = api($rpc, "wp.getPosts", array('post_type' => 'anime')); // sama kek new WP_Query()
  27.         foreach($list_id as $data){
  28.             $id = $data['post_id'];
  29.             $link = $data['link'];
  30.             $judul = $data['post_title'];
  31.             $result = api($rpc, "wp.editPost", $id);
  32.                 if($result){
  33.                     echo 'Post ID : '.$id.' -> Done -> <a href="'.$link.'">'.$judul.'</a><br>';
  34.                 }else{
  35.                     echo 'Post ID : '.$id.' -> Fail -> Something Wrong<br>';
  36.                 }
  37.         }
  38.     echo 'DONE';
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement