我在我的一个网站上使用以下自定义帖子类型:
function careers_post_type() {
$labels = array(
\'name\' => _x( \'Careers\', \'Post Type General Name\', \'text_domain\' ),
\'singular_name\' => _x( \'Career\', \'Post Type Singular Name\', \'text_domain\' ),
\'menu_name\' => __( \'Careers\', \'text_domain\' ),
\'parent_item_colon\' => __( \'Parent career:\', \'text_domain\' ),
\'all_items\' => __( \'All careers\', \'text_domain\' ),
\'view_item\' => __( \'View career\', \'text_domain\' ),
\'add_new_item\' => __( \'Add New career\', \'text_domain\' ),
\'add_new\' => __( \'New career\', \'text_domain\' ),
\'edit_item\' => __( \'Edit career\', \'text_domain\' ),
\'update_item\' => __( \'Update career\', \'text_domain\' ),
\'search_items\' => __( \'Search careers\', \'text_domain\' ),
\'not_found\' => __( \'No careers found\', \'text_domain\' ),
\'not_found_in_trash\' => __( \'No careers found in Trash\', \'text_domain\' ),
);
$args = array(
\'label\' => __( \'career\', \'text_domain\' ),
\'description\' => __( \'career information pages\', \'text_domain\' ),
\'labels\' => $labels,
\'supports\' => array( ),
\'taxonomies\' => array( ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'post\',
);
register_post_type( \'career\', $args );
}
吸盘工作得很好。但是,我想为其添加一个自定义功能。我使用了本教程:
http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types 一旦我将代码设置为这样,它就会停止工作:
// Register Custom Post Type
function careers_post_type() {
$labels = array(
\'name\' => _x( \'Careers\', \'Post Type General Name\', \'text_domain\' ),
\'singular_name\' => _x( \'Career\', \'Post Type Singular Name\', \'text_domain\' ),
\'menu_name\' => __( \'Careers\', \'text_domain\' ),
\'parent_item_colon\' => __( \'Parent career:\', \'text_domain\' ),
\'all_items\' => __( \'All careers\', \'text_domain\' ),
\'view_item\' => __( \'View career\', \'text_domain\' ),
\'add_new_item\' => __( \'Add New career\', \'text_domain\' ),
\'add_new\' => __( \'New career\', \'text_domain\' ),
\'edit_item\' => __( \'Edit career\', \'text_domain\' ),
\'update_item\' => __( \'Update career\', \'text_domain\' ),
\'search_items\' => __( \'Search careers\', \'text_domain\' ),
\'not_found\' => __( \'No careers found\', \'text_domain\' ),
\'not_found_in_trash\' => __( \'No careers found in Trash\', \'text_domain\' ),
);
$args = array(
\'label\' => __( \'career\', \'text_domain\' ),
\'description\' => __( \'career information pages\', \'text_domain\' ),
\'labels\' => $labels,
\'supports\' => array( ),
\'taxonomies\' => array( ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'career_editor\',
\'capabilities\' => array(
\'publish_posts\' => \'publish_career\',
\'edit_posts\' => \'edit_career\',
\'edit_others_posts\' => \'edit_others_career\',
\'delete_posts\' => \'delete_career\',
\'delete_others_posts\' => \'delete_others_career\',
\'read_private_posts\' => \'read_private_career\',
\'edit_post\' => \'edit_career\',
\'delete_post\' => \'delete_career\',
\'read_post\' => \'read_career\',
),
);
register_post_type( \'career\', $args );
}
我甚至尝试过去掉功能数组,但内容类型仍然消失了。我做错了什么?