Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function api($rpc, $method, $filter=null){
- global $USERNAME, $PASSWORD;
- $status = $rpc->query($method, "1", $USERNAME, $PASSWORD, $filter);
- if(!$status){
- print "Error (".$rpc->getErrorCode()."):";
- print $rpc->getErrorMessage()."\n";
- exit;
- }
- $comment = $rpc->getResponse();
- return $comment;
- }
- /*
- * https://codex.wordpress.org/XML-RPC_WordPress_API/Posts
- * http://scripts.incutio.com/xmlrpc/
- */
- $USERNAME = "USERNAME_WP";
- $PASSWORD = "PASS_WP";
- $xmlrpc_path = "http://nama.tld/xmlrpc.php";
- require "IXR_Library.php";
- $rpc = new IXR_Client($xmlrpc_path);
- $list_id = api($rpc, "wp.getPosts", array('post_type' => 'anime')); // sama kek new WP_Query()
- foreach($list_id as $data){
- $id = $data['post_id'];
- $link = $data['link'];
- $judul = $data['post_title'];
- $result = api($rpc, "wp.editPost", $id);
- if($result){
- echo 'Post ID : '.$id.' -> Done -> <a href="'.$link.'">'.$judul.'</a><br>';
- }else{
- echo 'Post ID : '.$id.' -> Fail -> Something Wrong<br>';
- }
- }
- echo 'DONE';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement