1
私は現在のサイトでカテゴリを作成しながらリモートサイトにカテゴリを作成する必要があります。私はadd_action( 'create_category'、 'func_create_theme'、10,2)を使いました。アクションフック。create categoryでxmlrpc callを使用するには?
関数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();
}