WooCommerce- How to remove product & product-category from urls? (ok)
https://stackoverflow.com/questions/43447175/woocommerce-how-to-remove-product-product-category-from-urls
Last updated
https://stackoverflow.com/questions/43447175/woocommerce-how-to-remove-product-product-category-from-urls
Last updated
Ask QuestionAsked 5 years, 6 months agoModified 1 year, 1 month agoViewed 78k times9
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?
Have you checked settings ->permalinks? – Yahya Hussein Apr 17, 2017 at 7:35
@Bhagya Shree it's not recommended, read this docs.woocommerce.com/document/… – kebir Apr 17, 2017 at 8:03
you should use of woocommerce seo perfect plugin because it's good for seo and create best url for you I use most way to remove category but I saw there are dot in canonical so i decided to use this plugin cheers – amh Sep 6, 2020 at 14:05
Sorted by: Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 23
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/
1Worked for me on latest Woocommerce 3.3.3. Thanks – Dr.MTR Mar 3, 2018 at 21:29
how to install this plugin? – ccdiego5 Mar 25, 2019 at 12:57
The class members should be properly isolated from the string: "SELECT t.term_id FROM " . $wpdb->terms . "...
– Daniel W. Nov 23, 2019 at 17:36
Add a commentReport this ad3
Noone mentioned how to remove /product/ so here it goes:
I've added priority since some themes/plugins can conflict with this rule, which happened to me.
This is a simple solution but it doesn't work if there is %product_cat% in the product base and there are multiple categories in the URL, for example: /parent-cat/child-cat/product-slug/ – Hasan Akhtar Oct 23, 2021 at 7:30
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.
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.
You can use the following filter: woocommerce_register_post_type_product
Here is an example if you only want to remove /product/ but keep the category.
Then make sure to flush the permalinks by updating the permalinks in the Admin panel.
Keep in mind you will still see '/product/' in the permalink structure in the Admin Panel Permalinks, but it will not have an affect.
How to remove the product name and only have the product id? – ZeroCode Dec 28, 2020 at 6:44
Other solutions all failed for me, after some trial and error I came up with this solution...
Install free 'WOO CATEGORY BASE PERMALINK FIXER' plugin from https://masterns-studio.com/code-factory/wordpress-plugin/woo-category-base/
Set Product Category Base Permalinks to : shop
Set Custom Base Permalinks to : /shop/%product_cat%/
URLs will then look like
Seems to work fine for pagination and sub categories
ShareEditFollowFlagedited Sep 7, 2020 at 6:55General Grievance4,3312424 gold badges2828 silver badges4343 bronze badgesasked Apr 17, 2017 at 7:30Bhagya Shree9111 gold badge11 silver badge33 bronze badges
ShareEditFollowFlaganswered May 14, 2017 at 11:21Shehroz Altaf60811 gold badge1010 silver badges1616 bronze badges
ShareEditFollowFlaganswered Sep 5, 2021 at 7:13Goran Jakovljevic2,49311 gold badge2626 silver badges2424 bronze badges
ShareEditFollowFlaganswered Jan 21, 2020 at 15:08Alex2111 bronze badgeAdd a comment1
ShareEditFollowFlagedited Mar 19, 2019 at 11:11AS Mackay2,79399 gold badges1818 silver badges2525 bronze badgesanswered Mar 19, 2019 at 10:52Manu Garrido1144 bronze badgesAdd a comment1