我创建了一个自定义帖子类型,下面是完整的代码:
// Register Custom Post Type
function wrestler_register() {
$labels = array(
\'name\' => _x( \'Wrestlers\', \'Post Type General Name\', \'text_domain\' ),
\'singular_name\' => _x( \'Wrestler\', \'Post Type Singular Name\', \'text_domain\' ),
\'menu_name\' => __( \'Wrestler Profiles\', \'text_domain\' ),
\'parent_item_colon\' => __( \'Parent Item:\', \'text_domain\' ),
\'all_items\' => __( \'All Items\', \'text_domain\' ),
\'view_item\' => __( \'View Item\', \'text_domain\' ),
\'add_new_item\' => __( \'Add New Profile\', \'text_domain\' ),
\'add_new\' => __( \'Add New\', \'text_domain\' ),
\'edit_item\' => __( \'Edit Item\', \'text_domain\' ),
\'update_item\' => __( \'Update Item\', \'text_domain\' ),
\'search_items\' => __( \'Search Item\', \'text_domain\' ),
\'not_found\' => __( \'Not found\', \'text_domain\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\', \'text_domain\' ),
);
$rewrite = array(
\'slug\' => \'wrestler\',
\'with_front\' => true,
\'pages\' => false,
\'feeds\' => false,
);
$args = array(
\'label\' => __( \'wrestler_profiles\', \'text_domain\' ),
\'description\' => __( \'Profiles of WWE Superstars & Divas\', \'text_domain\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'thumbnail\', \'custom-fields\', ),
\'hierarchical\' => true,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'menu_icon\' => url + \'/icon.png\',
\'can_export\' => true,
\'has_archive\' => false,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'rewrite\' => $rewrite,
\'query_var\' => \'wrestler\',
\'capability_type\' => \'page\',
);
register_post_type( \'wrestler_profiles\', $args );
}
// Hook into the \'init\' action
add_action( \'init\', \'wrestler_register\', 0 );
现在,我还增加了单人摔跤手。php到我的主题的根目录,但每次我查看页面时,它都会落在“Single.php”上。
谢谢