[英]Separate product archive page for Woocommerce taxonomy
我將此自定義分類法添加到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' );
}
我已經從各處嘗試了很多代碼,但似乎無法做到這一點:(
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.