Php 没有在wordpress中获取自定义帖子的类别?

Php 没有在wordpress中获取自定义帖子的类别?,php,wordpress,rest,Php,Wordpress,Rest,我正在为wordpress Web服务使用WP REST API插件和Jetpack插件。因此,最初“Vehicle”是我的自定义帖子类型,其中包括两种类型 二轮车和四轮车的分类。所以,目前我没有在webservice结果ie中获得分类法。 . 下面是我的代码 /*************************************************** * Register a two-wheeler, four-wheeler taxonomy with Vehicle po

我正在为wordpress Web服务使用WP REST API插件和Jetpack插件。因此,最初“Vehicle”是我的自定义帖子类型,其中包括两种类型 二轮车和四轮车的分类。所以,目前我没有在webservice结果ie中获得分类法。 . 下面是我的代码

/***************************************************
   * Register a two-wheeler, four-wheeler taxonomy with Vehicle post type, with REST API support
   ***************************************************/
  add_action( 'init', 'vehicle_group_taxonomy', 30 );
  function vehicle_group_taxonomy() {

    $labels = array(
        'name'              => _x( 'two_wheeler', 'taxonomy general name' ),
        'singular_name'     => _x( 'two_wheeler', 'taxonomy singular name' ),
        'search_items'      => __( 'Search two_wheeler' ),
        'all_items'         => __( 'All two_wheeler' ),
        'parent_item'       => __( 'Parent two_wheeler' ),
        'parent_item_colon' => __( 'Parent two_wheeler:' ),
        'edit_item'         => __( 'Edit two_wheeler' ),
        'update_item'       => __( 'Update two_wheeler' ),
        'add_new_item'      => __( 'Add New two_wheeler' ),
        'new_item_name'     => __( 'New two_wheeler Name' ),
        'menu_name'         => __( 'two_wheeler' ),
    );

    $args = array(
        'hierarchical'      => true,
        'labels'            => $labels,
        'show_ui'           => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => array( 'slug' => 'two_wheeler' ),
        'show_in_rest'       => true,
        'rest_base'          => 'two_wheeler',
        'rest_controller_class' => 'WP_REST_Terms_Controller',
    );

     register_taxonomy( 'two_wheeler', array( 'vehicle' ), $args );

    $labels_speciality = array(
        'name'              => _x( 'four_wheeler', 'taxonomy general name' ),
        'singular_name'     => _x( 'four_wheeler', 'taxonomy singular name' ),
        'search_items'      => __( 'Search four_wheeler' ),
        'all_items'         => __( 'All four_wheeler' ),
        'parent_item'       => __( 'Parent four_wheeler' ),
        'parent_item_colon' => __( 'Parent four_wheeler:' ),
        'edit_item'         => __( 'Edit four_wheeler' ),
        'update_item'       => __( 'Update four_wheeler' ),
        'add_new_item'      => __( 'Add New four_wheeler' ),
        'new_item_name'     => __( 'New four_wheeler Name' ),
        'menu_name'         => __( 'four_wheeler' ),
    );

    $args_speciality = array(
        'hierarchical'      => true,
        'labels'            => $labels_speciality,
        'show_ui'           => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => array( 'slug' => 'four_wheeler' ),
        'show_in_rest'       => true,
        'rest_base'          => 'four_wheeler',
        'rest_controller_class' => 'WP_REST_Terms_Controller',
    );

    register_taxonomy( 'four_wheeler', array( 'vehicle' ), $args_speciality );

  }

   /********************************************************
  * Add REST API support to an already registered post type.
  *********************************************************/
  add_action( 'init', 'my_custom_post_type_rest_support', 25 );
  function my_custom_post_type_rest_support() {
    global $wp_post_types;

    //be sure to set this to the name of your post type!
    $post_type_name = 'vehicle';
    if( isset( $wp_post_types[ $post_type_name ] ) ) {
        $wp_post_types[$post_type_name]->show_in_rest = true;
        $wp_post_types[$post_type_name]->rest_base = $post_type_name;
        $wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';
    }

  }


   /*******************************************************
  * Add REST API support to an already registered taxonomy.
  *********************************************************/
  add_action( 'init', 'my_custom_taxonomy_rest_support', 25 );
  function my_custom_taxonomy_rest_support() {
    global $wp_taxonomies;

    //be sure to set this to the name of your taxonomy!
    $taxonomy_name = array('two_wheeler','four_wheeler');

    if ( isset( $wp_taxonomies[ $taxonomy_name ] ) ) {
        $wp_taxonomies[ $taxonomy_name ]->show_in_rest = true;
        $wp_taxonomies[ $taxonomy_name ]->rest_base = $taxonomy_name;
        $wp_taxonomies[ $taxonomy_name ]->rest_controller_class = 'WP_REST_Terms_Controller';
    }
  }

问题是什么?将类别设置为空作为响应,例如:“菜单顺序”:0“页面模板”:““公布URL”:[]”标记“{}”类别“{}”附件“{}”。没有获取我在上述代码中注册的类别有什么问题?将类别获取为空以响应例如:“菜单顺序”:0“页面模板”:““公布URL”:[]”“标记”:{}“类别”:{}“附件”:{}。没有得到我在上面代码中注册的类别