我刚刚在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' );
Run Code Online (Sandbox Code Playgroud)
如下图所示,分类标准显示在左侧导航中,但是当我的(管理员)用户单击选项时,我显示为" 您不允许编辑此项目".错误:

任何人都可以建议为什么这可能?
几乎我发布这个,我意识到它是capabilities阵列.删除它,以便它恢复到默认值允许按预期访问.
经过进一步调查后,我发现以下是正确运行的最佳设置:
'capabilities' => array(
'manage__terms' => 'edit_posts',
'edit_terms' => 'manage_categories',
'delete_terms' => 'manage_categories',
'assign_terms' => 'edit_posts'
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1372 次 |
| 最近记录: |