我已创建了自定义分类法,如中所述the Codex. 我将“public”设置为true,show\\u in\\u nav\\u menus应该继承自,并且还显式添加了show\\u in\\u nav\\u menus变量并将其设置为true。但是,它只显示给用户名为“Admin”的用户。其他用户都无法在“外观”>“菜单”下看到它,即使是标记为“管理员”的用户。
这是我的确切代码:
function create_con_casino_reviews() {
register_post_type( \'con_casino_reviews\',
array(
\'labels\' => array(
\'name\' => __( \'Casino Reviews\' , \'continuum\'),
\'singular_name\' => __( \'Casino Review\' , \'continuum\'),
\'add_new\' => __(\'Add new review\', \'continuum\'),
\'edit_item\' => __(\'Edit review\', \'continuum\'),
\'new_item\' => __(\'New review\', \'continuum\'),
\'view_item\' => __(\'View review\', \'continuum\'),
\'search_items\' => __(\'Search reviews\', \'continuum\'),
\'not_found\' => __(\'No reviews found\', \'continuum\'),
\'not_found_in_trash\' => __(\'No reviews found in Trash\', \'continuum\')
),
\'public\' => true,
\'menu_position\' => 25,
\'menu_icon\' => get_stylesheet_directory_uri() . \'/images/review-casino.png\',
\'rewrite\' => array(\'slug\' => \'casino-review\'),
\'supports\' => array(\'title\',\'editor\',\'author\',\'thumbnail\',\'excerpt\',\'trackbacks\',\'custom-fields\',\'comments\',\'revisions\'),
\'taxonomies\' => array(\'category\', \'post_tag\'),
\'show_in_nav_menus\' => true
)
);
}
add_action( \'init\', \'create_con_casino_reviews\' );
如果我更改:
register_post_type( \'con_casino_reviews\',
将成为:
register_post_type( \'con_casino_reviewss\',
它工作得很好。
SO网友:kevin
打开\'Screen Options\' “管理”右上角的菜单,旁边是\'Help\' 按钮还有其他用户名?
我有点困惑,因为你的代码没有显示任何register_post_type()
作用另外,是否要创建custom post type 或acustom taxonomy?
尝试使用此基本代码创建自定义帖子类型,看看它是否适合您:
/* books custom post type */
add_action( \'init\', \'create_books\' );
function create_books() {
register_post_type( \'cpt-books\',
array(
\'labels\' => array(
\'name\' => __( \'Books\' ),
\'singular_name\' => __( \'Book\' )
),
\'public\' => true,
\'show_ui\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'menu_position\' => 4,
\'query_var\' => true,
\'supports\' => array( \'title\', \'editor\' )
)
);
}