[英]Custom taxonomy is not working in custom post wordpress
如何使用此代碼添加分類法? 當我單擊新分類法時,出現錯誤
function people_init() {
// create a new taxonomy
register_taxonomy(
'people',
'new_post',
array(
'label' => __( 'People' ),
'rewrite' => array( 'slug' => 'person' ),
'capabilities' => array(
'assign_terms' => 'edit_guides',
'edit_terms' => 'publish_guides'
)
)
);
}add_action( 'init', 'people_init' );
這是錯誤消息:
您無權編輯此項目。
試試下面的代碼:
function people_init() {
// create a new taxonomy
register_taxonomy(
'people',
'new_post',
array(
'label' => __( 'People' ),
'rewrite' => array( 'slug' => 'person' ),
)
);
}add_action( 'init', 'people_init' );
這是令人討厭的代碼。 刪除它可以讓您創建和編輯術語。
'capabilities' => array(
'assign_terms' => 'edit_guides',
'edit_terms' => 'publish_guides'
)
功能edit_guides
和publish_guides
在默認情況下不存在,需要先為選定的用戶創建,然后再重新添加。有關如何執行此操作的詳細信息,請參閱Wordpress Codex中的add_cap()
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.