首页 视频课程 WordPress开发文档分类标签与页面 注册分类法

注册分类法

2020-04-03 / 5724阅

本视频需要登录以后才能播放

登录

简单注册-在类中使用

public function add_tax_init()
{
       register_taxonomy(
              $this->tax,
              $this->type,
              array(
                     'labels' => array(
                            'name' => $this->tax_name,
                            'add_new' => '新增',
                            'add_new_item' => '添加',
                            'new_item_name' => "新" . $this->tax_name,
                     ),
                     'show_ui' => true,
                     'show_tagcloud' => true,
                     'hierarchical' => true,
                     'show_in_rest' => true
              )
       );
}
add_action('init', array($this, 'add_tax_init')); 

简单注册 - 一般函数使用

function add_tax_init()
{
       register_taxonomy(
              '分类法名称',
              '文章类型',
              array(
                     'labels' => array(
                            'name' => '新分类法',
                            'add_new' => '新增',
                            'add_new_item' => '添加',
                            'new_item_name' => "新分类法",
                     ),
                     'show_ui' => true,
                     'show_tagcloud' => true,
                     'hierarchical' => true,
                     'show_in_rest' => true
              )
       );
}
add_action('init','add_tax_init');  

阅读文章或者观看视频过程中有任何问题,请下方留言或者联系我Q248758228

大家谈论
    我的见解
    目录