【问题标题】:How to use xmlrpc call on create category?如何在创建类别上使用 xmlrpc 调用?
【发布时间】:2017-07-21 10:49:33
【问题描述】:

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

函数 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();

  }

【问题讨论】:

    标签: php ajax wordpress xml-rpc


    【解决方案1】:

    您错过了以下几行。可能是这个原因。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-29
      • 1970-01-01
      • 2012-10-25
      • 2017-04-12
      相关资源
      最近更新 更多