I’ve added custom shared taxonomy season
for product
type from woocommerce and my custom type care
. Care
type and taxonomy are created in functions.php
file of my custom theme.
add_action('init', function() {
register_post_type('care', array(
'labels' => array(
'name' => __('Cares'),
'singular_name' => __('Care'),
),
'menu_position' => 4,
'public' => true,
'show_ui' => true,
'has_archive' => true,
'publicly_queryable' => true,
'supports' => array('title')
));
register_taxonomy( 'season',
array('product', 'care'),
array(
'label' => __('Season'),
'show_ui' => true,
'hierarchical' => true,
)
);
});
Now when I access season
taxonomy term, no matter which post_type
been passed, I always get to woocommerce products archive, i.e. http://example.com/?season=helloworld&post_type=product and http://example.com/?season=helloworld&post_type=care lead to the same page with woocommerce products archive.
How to make woocommerce share taxonomy properly?
P.S. Using WordPress 3.8.1 and Woocommerce 2.0.20. No explicit rewrite rules added.
Found solution for this problem.
It turned out that woocommerce affects
post_type
query variable inpre_get_posts
filter without checking that anotherpost_type
has been requested. It’s done inWC_Query.product_query
method:Fix for this problem is simple. You just need to check that
product
post type has been actually requested in the beginning ofproduct_query
method:After that everything works fine.
Update:
Fix has been merged into woocommerce master branch: https://github.com/woothemes/woocommerce/pull/4582.