我刚刚注册了一个新的Custom Taxonomy in Wordpress(根据文档)。以下是functions.php
中代码的副本供参考:
function people_init() {
// create a new taxonomy
register_taxonomy(
'people',
'post',
array(
'label' => __( 'People' ),
'rewrite' => array( 'slug' => 'person' ),
'capabilities' => array(
'assign_terms' => 'edit_guides',
'edit_terms' => 'publish_guides'
)
)
);
}
add_action( 'init', 'people_init' );
如下图所示,分类标准显示在左侧导航栏中,但当我的(管理员)用户点击选项时,我显示的是您不允许编辑此项目。错误:
有谁能说明为什么会这样?
答案 0 :(得分:9)
几乎在我发布此消息后,我意识到它是capabilities
数组。删除它,以便恢复为默认值允许按预期进行访问。
经过进一步调查后,我发现以下是正确运行的最佳设置:
'capabilities' => array(
'manage__terms' => 'edit_posts',
'edit_terms' => 'manage_categories',
'delete_terms' => 'manage_categories',
'assign_terms' => 'edit_posts'
)