您需要注册自己的自定义帖子类型。我建议您将此添加到函数文件中,并根据需要进行调整,而不是试图弄清楚如何正确执行此操作(如其他答案所述):
function custom_post_type() {
// Set UI labels for Custom Post Type
$labels = array(
\'name\' => _x( \'Staff\', \'Post Type General Name\' ),
\'singular_name\' => _x( \'Staff\', \'Post Type Singular Name\' ),
\'menu_name\' => __( \'Staff\' ),
\'parent_item_colon\' => __( \'Parent Staff\' ),
\'all_items\' => __( \'All Staff\' ),
\'view_item\' => __( \'View Staff\' ),
\'add_new_item\' => __( \'Add New Staff\' ),
\'add_new\' => __( \'Add New\' ),
\'edit_item\' => __( \'Edit Staff\' ),
\'update_item\' => __( \'Update Staff\' ),
\'search_items\' => __( \'Search Staff\' ),
\'not_found\' => __( \'Not Found\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\' ),
);
$args = array(
\'label\' => __( \'staff\' ),
\'description\' => __( \'Staff List\'),
\'labels\' => $labels,
// Features this CPT supports in Post Editor
\'supports\' => array( \'title\', \'author\', \'revisions\', \'author\', \'thumbnail\', \'excerpt\', \'revisions\', \'page-attributes\'),
// You can associate this CPT with a taxonomy or custom taxonomy.
\'taxonomies\' => array( \'category\' ),
/* A hierarchical CPT is like Pages and can have
* Parent and child items. A non-hierarchical CPT
* is like Posts.
*/
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'menu_icon\' => \'dashicons-businessman\',
\'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\' => \'page\',
);
// Registering your Custom Post Type
register_post_type( \'staff\', $args );
}
add_action( \'init\', \'custom_post_type\', 0 );
然后你可以
single-staff.php
和
archive-staff.php
显示员工结果。分类为
category
如上所述,它将设置类别,以便您可以使用该类别创建菜单项。