Home How to make duplicate of product category taxonomy in Woocommerce
Reply: 0

How to make duplicate of product category taxonomy in Woocommerce

user3008 Published in April 20, 2018, 10:41 am

I want to add new custom taxonomy in wordpress. So, to do this, I have used the register_taxonomy() function and in this, I have made the duplicate of product_cat taxonomy.

Below is the code of my custom taxonomy:

add_action('woocommerce_register_taxonomy', 'fancyplugin_register_custom_taxonomy');  

function fancyplugin_register_custom_taxonomy()
           'hierarchical' => true,
            'update_count_callback' => '_wc_term_recount',
            'label' => __('Publishers', 'woocommerce'),
            'labels' => array(
                 'name' => __('Product publishers', 'woocommerce'),
                 'singular_name' => __('Publisher', 'woocommerce'),
                 'menu_name' => _x('Publishers', 'Admin menu name', 'woocommerce'),
                 'search_items' => __('Search publishers', 'woocommerce'),
                 'all_items' => __('All publishers', 'woocommerce'),
                 'parent_item' => '',
                 'parent_item_colon' => '',
                 'edit_item' => __('Edit Pubisher', 'woocommerce'),
                 'update_item' => __('Update Publisher', 'woocommerce'),
                 'add_new_item' => __('Add new publisher', 'woocommerce'),
                 'new_item_name' => __('New publisher name', 'woocommerce'),
                 'not_found' => __('No publishers found', 'woocommerce'),
           'show_ui' => true,
           'query_var' => true,
           'capabilities' => array(
               'manage_terms' => 'manage_product_terms',
               'edit_terms' => 'edit_product_terms',
               'delete_terms' => 'delete_product_terms',
               'assign_terms' => 'assign_product_terms',
            'rewrite' => array(
               'slug' => 'publisher',
               'with_front' => false,
               'hierarchical' => true,  

I have also added template "taxonomy-publisher.php" in woocommerce template folder same as like taxonomy-product_cat.php. After this, I have added some publishers into this taxonomy and map some products into it.

When I click on any publisher on front end, then website is showing me "Ooops! That page can't be found". When I go to little more deep to check the why the wordpress is not returning correct template file. And I found that, is_product_taxonomy() function returning false.

But when click on any product category then website showing me mapped products as well as is_product_taxonomy() function returns true in this case. So, I am not able to understand, why the wordpress is not able to show me right thing although I have used same information (product_cat taxonomy) in my custom taxonomy.

Please can anyone share your solution. Thanks in Advance

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299366 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO