创建自定义分类法但无法创建新项目,字段消失了

Creating custom taxonomies but can't create new item, fields are gone

我刚刚创建了一个新的自定义 post 类型和自定义分类法,并将其链接到我创建的自定义 post 类型。问题是我无法在自定义分类法上添加新项目,因为字段已消失?

查看屏幕截图。

click me for screenshot

这是我的代码:

    function create_post_type_deals() {
  register_post_type( 'deals',
    array(
      'labels' => array(
       'name' => __( 'Deals' ),
       'singular_name' => __( 'deal' )
      ),

      'public' => true,
      'has_archive' => true,
      'rewrite' => array('slug' => 'deal'),
      'taxonomies' => array('tags', 'category', 'deal_type' ),
    )
  );
}

add_action( 'init', 'create_post_type_deals' );

//Register new taxonomy DEAL TYPE MC
function deals_init() {
    // create a new taxonomy
    register_taxonomy(
        'deal_type',
        'deals',
        array(
            'label' => __( 'Deal Type' ),
            'rewrite' => array( 'slug' => 'deal-type' ),
            'capabilities' => array(
                'assign_terms' => 'edit_guides',
                'edit_terms' => 'publish_guides'
            ),
            'labels' => array(
            )
        )
    );
}
add_action( 'init', 'deals_init' );

问题是你的能力。

使用

'capabilities' => array(
  'assign_terms' => 'edit_posts',
  'edit_terms' => 'publish_posts'
)

将使其正确显示。我假设您当前的功能没有定义或类似的东西。仔细检查您是否正确设置了功能。

此外,您遗漏了很多标签,因此我建议使用此工具进行自定义分类和自定义 post 类型:https://generatewp.com/taxonomy/