我正在尝试为自定义分类法创建自定义模板。例如,我在WP中注册了一个带有品牌的自定义分类法,slug brandi使用以下代码注册自定义分类法。
function brand() {
$labels = array(
\'name\' => _x( \'brands\', \'Taxonomy General Name\', \'text_domain\' ),
\'singular_name\' => _x( \'brand\', \'Taxonomy Singular Name\', \'text_domain\' ),
\'menu_name\' => __( \'Brands\', \'text_domain\' ),
\'all_items\' => __( \'All Brands\', \'text_domain\' ),
\'parent_item\' => __( \'Brand Parent Item\', \'text_domain\' ),
\'parent_item_colon\' => __( \'Parent Item:\', \'text_domain\' ),
\'new_item_name\' => __( \'New Brand\', \'text_domain\' ),
\'add_new_item\' => __( \'Add New Brand\', \'text_domain\' ),
\'edit_item\' => __( \'Edit Brand\', \'text_domain\' ),
\'update_item\' => __( \'Update Brand\', \'text_domain\' ),
\'view_item\' => __( \'View Brand\', \'text_domain\' ),
\'separate_items_with_commas\' => __( \'Separate items with commas\', \'text_domain\' ),
\'add_or_remove_items\' => __( \'Add or remove Brands\', \'text_domain\' ),
\'choose_from_most_used\' => __( \'Choose from the most used\', \'text_domain\' ),
\'popular_items\' => __( \'Popular Brands\', \'text_domain\' ),
\'search_items\' => __( \'Search Brands\', \'text_domain\' ),
\'not_found\' => __( \'Not Found\', \'text_domain\' ),
);
$rewrite = array(
\'slug\' => \'brand\',
\'with_front\' => true,
\'hierarchical\' => true,
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
\'public\' => true,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'show_in_nav_menus\' => true,
\'show_tagcloud\' => true,
\'rewrite\' => $rewrite,
);
register_taxonomy( \'brand\', array( \'product\' ), $args );
}
// Hook into the \'init\' action
add_action( \'init\', \'brand\', 0 );
我试图创建一个模板,在页面中显示品牌分类的详细信息。我尝试使用名称创建页面模板
taxonomy-brand.php (taxonomy-{slug}.php)
taxonomy-brands.php (taxonomy-{name}.php)
single-brand.php (single-{slug}.php)
single-brands.php (single-{name}.php)
但它们不起作用,wordpress正在单曲上展示品牌细节。php,而不是显示在自定义模板上。请告诉我哪里做错了。
非常感谢。