2017-12-18 77 views

回答

0

...这回答比上面一个稍微不同的问题...

您需要启用,你所定义的分类标准的REST API。

只需添加'show_in_rest_api' => true

事情是这样的:

<?php 
add_action('init', 'create_book_tax'); 

function create_book_tax() { 
    register_taxonomy(
     'genre', 
     'book', 
     array(
      'label' => __('Genre'), 
      'rewrite' => array('slug' => 'genre'), 
      'hierarchical' => true, 
      'show_in_rest_api' => true // <-- Do This! 
     ) 
    ); 
} 
?>