I have these post types :
- Articles (blog),
- Hotels (custom post type),
- Products Activities (WooCommerce products with a product_cat Activities)
- Products Transportation (WooCommerce products with product_cat Transportation).
All these post types can be linked to a single tag (the default Wordpress Post Tags).
I want distinct tags URLs for each post type, like this :
- Articles : /tag/{tag}
(the default one, working normally, with pagination etc.)
- Hotels : /hotels/tag/{tag}
- Activities : /activities/tag/{tag}
- Transportation : /transportation/tag/{tag}
For the last 3 I managed to setup custom rewrite rules to have these URI working :
Hotels :
add_rewrite_rule( 'hotels/([^/]+)', 'index.php?tag=$matches[1]&post_type=hotels', 'top' );
and for pagination :
add_rewrite_rule( 'hotels/([^/]+)/page/([0-9]{1,})/?', 'index.php?tag=$matches[1]&post_type=hotels&pages=$matches[2]', 'top' );
Products Activities :
add_rewrite_rule( 'activities/tag/([^/]+)', 'index.php?tag=$matches[1]&product_cat=activities', 'top' );
and for pagination :
add_rewrite_rule( 'activities/([^/]+)/page/([0-9]{1,})/?', 'index.php?tag=$matches[1]&product_cat=activities&pages=$matches[2]', 'top' );
Products Transportation :
add_rewrite_rule( 'transportation/tag/([^/]+)', 'index.php?tag=$matches[1]&product_cat=transportation', 'top' );
and for pagination :
add_rewrite_rule( 'transportation/([^/]+)/page/([0-9]{1,})/?', 'index.php?tag=$matches[1]&product_cat=transportation&pages=$matches[2]', 'top' );
This is working for the Hotels query. For the products query it's working except for pagination. The pagination is well displayed on page 1, but if I click on page 2 button I go to activites/tag/{tag}/page/2
but it stills displays page 1. Is there something special to do for WooCommerce ?
thanks