我在WordPress 4.4上有一个主题,其中包含此文件functions.php
:
<?php
function post_types(){
$labels = array(
\'name\' => __( \'Newsletters\'),
\'singular_name\' => __( \'Newsletter\'),
\'menu_name\' => __( \'Newsletters\'),
\'name_admin_bar\' => __( \'Newsletter\'),
\'add_new\' => __( \'Add New\'),
\'add_new_item\' => __( \'Add New Newsletter\'),
\'new_item\' => __( \'New Newsletter\'),
\'edit_item\' => __( \'Edit Newsletter\'),
\'view_item\' => __( \'View Newsletter\'),
\'all_items\' => __( \'All Newsletters\'),
\'search_items\' => __( \'Search Newsletters\'),
\'parent_item_colon\' => __( \'Parent Newsletters\'),
\'not_found\' => __( \'No Newsletters found.\'),
\'not_found_in_trash\' => __( \'No Newsletters found in Trash.\')
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'show_in_menu\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'newsletter\' ),
\'capability_type\' => array(\'newsletter\',\'newsletters\'),
\'has_archive\' => true,
\'hierarchical\' => true,
\'menu_position\' => 5,
\'supports\' => array( \'title\',\'thumbnail\',\'comments\',\'editor\',\'excerpt\' )
);
register_post_type( \'newsletter\', $args );
}
add_action(\'init\', \'post_types\');
?>
我的“管理”菜单上没有新闻稿,我也不知道我做错了什么。
最合适的回答,由SO网友:birgire 整理而成
问题很可能是这一部分:
\'capability_type\' => array(\'newsletter\',\'newsletters\'),
尝试将其拆下或进行相应调整。
你也应该prefix 您的函数可以避免可能的名称冲突。因此,请更换:
function post_type() {
至,例如。
function arcath_post_type() {
同样地:
add_action(\'init\', \'arcath_post_types\');