Separate product archive page for Woocommerce taxonomy

I added this custom taxonomy to Woocommerce, it’s very standard from woothemes documentation. I need Woocommerce to check if what is currently being viewed is a range taxonomy e.g./product-range/fairy-falls/ then this template needs to be used: archive-product-ranges.php which is located in my main theme folder under woocommerce (fortblanket/woocommerce/archive-product-ranges.php)

Here is the taxonomy i added to functions.php:

Read More
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' );
}

I have tried so many bits of code from all over the place, I can’t seem to get this right 🙁

Related posts

1 comment

  1. The cause behind this issue is that you haven’t added any code for loading the custom template which you have created. And even the name scheme of the taxonomy file is also not correct as per the WordPress standard.

    Rectifying both the causes will make your code work.

    Please go through this link for more information.

Comments are closed.