2017-07-21 18 views
1

我只需要在远程站点上创建类别,同时在当前站点上创建类别。我使用了add_action('create_category','func_create_theme',10,2);动作钩子。如何在创建类别上使用xmlrpc调用?

函数func_create_theme()是通过ajax调用执行的。

谢谢

add_action('create_category', 'func_create_theme', 10, 2); 

    function func_create_theme($catId){ 

     $category = get_category($catId); 

     $usr = 'upsol'; 
     $pwd = 'change2'; 

     $xmlrpc = 'http://localhost/~rocky/demo2/xmlrpc.php'; 
     $client = new WP_HTTP_IXR_CLIENT($xmlrpc); 

     $postcontent = array(
      'name' => $category->name, 
      'taxonomy' => 'category', 
      'slug' => $category->slug 
     ); 

     $res = $client -> query('wp.newTerm',1, $usr, $pwd, $postcontent); 
     echo $postID = $client->getResponse(); 

    } 

回答

0

你错过以下行。可能是原因。

include_once(ABSPATH . WPINC . '/class-IXR.php'); 
include_once(ABSPATH . WPINC . '/class-wp-http-ixr-client.php'); 
相关问题