我将此自定义分类法添加到Woocommerce,它是woothemes文档中非常标准的。我需要Woocommerce来检查当前正在查看的内容是否是范围分类法,例如/ product-range / fairy-falls /然后需要使用此模板:archive-product-ranges.php位于我的主题文件夹下的woocommerce (fortblanket / woocommerce /归档产品ranges.php)
这是我添加到functions.php的分类法:
add_action( 'init', 'create_ranges_taxonomies', 0 );
function create_ranges_taxonomies() {
$labels = array(
'name' => 'Product Ranges',
'singular_name' => 'Product Range',
'menu_name' => 'Product Ranges',
'all_items' => 'All Ranges',
'parent_item' => 'Parent Range',
'parent_item_colon' => 'Parent Range:',
'new_item_name' => 'New Range Name',
'add_new_item' => 'Add New Range',
'edit_item' => 'Edit Range',
'update_item' => 'Update Range',
'separate_items_with_commas' => 'Separate Range with commas',
'search_items' => 'Search Ranges',
'add_or_remove_items' => 'Add or remove Ranges',
'choose_from_most_used' => 'Choose from the most used Ranges',
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'product-range' ),
);
register_taxonomy( 'product_range', 'product', $args );
register_taxonomy_for_object_type( 'product_range', 'product' );
}
我已经尝试了很多来自各地的代码,我似乎无法做到这一点:(
答案 0 :(得分:0)