I'm using WooCommerce on a WordPress and it adds product & product-category to the
URLs.
http://dev.unwaveringmedia.com/8dim/product-category/all-party-supplies/ http://dev.unwaveringmedia.com/8dim/product/14-snowman-serving-tray/
I need to remove 'product' & 'product-category' from the URLs. Is there any way to modify the permalinks and remove them?
Using Shehroz Altaf's trick does the job just (almost) perfectly.
Adding the following between the
$slug
and$exists
declarations will make it work with sub-categories too.Other solutions all failed for me, after some trial and error I came up with this solution...
URLs will then look like
Seems to work fine for pagination and sub categories
Yes. But Please read this article first https://docs.woocommerce.com/document/removing-product-product-category-or-shop-from-the-urls/
You can change this by:
you can change the permalinks in Settings > permalink > optional > Product category base= ./ (type ./ in Product category base).
Be sure that you don’t have any page, post or attachment with the same name (slug) as the category page or they will collide and the code won’t work.
Install and activate the plugin below: (For more info please see https://timersys.com/remove-product-category-slug-woocommerce/)
`
For more info please see https://timersys.com/remove-product-category-slug-woocommerce/
It wasn't working with pagination for me. Here is full code that's working.
This will add new rewrite rule that will paginate query.