It’s actually quite simple. Use the woocommerce_product_post_type_link_parent_category_only
filter:
add_filter( 'woocommerce_product_post_type_link_parent_category_only', '__return_true' );
Tried and tested working.
PS: The code would go into the theme functions file and __return_true()
is a WordPress function.
Related Posts:
- How to remove product base from WooCommerce product permalinks
- Unable to update Woocommerce Product Permalink
- Permalinks contain unwanted space resulting in broken links
- Subcategories not working when using shared base with custom taxonomy
- WooCommerce product category permalinks
- Add Custom Slug Tags Per Page
- How to rewrite product permalinks in Woocommerce to use category slugs
- Add only sku to product url woocoomerce
- Woocommerce Product permalinks “product” word is not working
- Custom WooCommerce rewrite rules with comma delimiter
- How to change product category permalinks programmatically?
- One Time Access URL after purchasing subscription
- WooCommerce return 404 in the product page
- How to update permalink programmatically?
- How to remove the Sub category product URL Woocommerce
- Woocommerce posts and products links works only once and then get 404 error
- Custom pagination permalink structure Product page
- Adding country subdomain to an existing website like www.example.com/uk
- WooCommerce product id as permalink
- Woocommerce product and category in url [closed]
- WooCommerce product permalink based on product’s current category
- How to display product price of the product in loop
- Limit users to one active subscription in WooCommerce Subscriptions? [closed]
- WooCommerce add_to_cart() with custom price [closed]
- WooCommerce HTML after short description if product is in specific category
- How to get total count for each star rating?
- WooCommerce change category url and product base
- WooCommerce Apply Coupon to order AFTER taxes
- Rewriting Woocommerce Product Filters To URL Segments
- Auto update cart after quantity change
- echo product id and product_item_key in cart [closed]
- Redirect the single product page link to the shop page
- woocommerce_get_price filter hook not working for product variation price
- WooCommerce shipping – Different product different shipping? [closed]
- Remove action added through function
- Filter get_adjacent_post to follow woocommerce product category
- Run function on “Place Order” [closed]
- Displaying Custom Input Value to Customer Order Details (My Account) page in Woocommerce
- Add custom order meta to Order Completed email
- Hiding products with a specific tag from WooCommerce main shop page
- How to upload Woocommerce product images via API? [closed]
- how to do a processing Orders into Complete after x Minutes or x hour in WooCommerce [closed]
- show content of a page built using yootheme builder on different page/template
- How to detect if this post is a woocommerce product?
- Set a custom field to all orders
- Force User Registration before visitng Checkout Page
- Tax Query for custom Taxonomy field
- Improve WooCommerce checkout process [closed]
- How can I put the contents of My Account > Order into a separate page, Woocommerce
- Feed format for woocommerce [closed]
- Convert WordPress Woocomerce product to WordPress post
- How to get woocommerce product collection in template file
- How to set the meta description of a WooCommerce product as its primary category description?
- Woocommerce product rewrite rules not working
- How to display a table below each product in product list/loop
- how to remove this image? [closed]
- Create a shortcode for native WooCommerce search form [closed]
- WooCommerce – Split Multiple Items into Individual Line Items
- Change “Select Options” label in button to “Buy Now!” in store page
- How to use Custom Field to display product brief description in shop page with Woocommerce?
- I want to filter my products with attributes [closed]
- Woocommerce product import exports product with price rounded to integer? [closed]
- How to hook to function of woocommerce product export _regular_price?
- Adding preference buttons to main nav that persist via user sessions. (Woocommerce)
- Woocommerce custom log in and register
- Add “new” tag for existing products
- CallBack URL for payment gateway redirecting to homepage instead of executing callback function
- Display when items are in Woocommerce cart but hide when empty
- Printing product variation return array to string conversion error
- woocommerce deposit Form with AJAX and shortcode won’t update but add to previous output
- How to retrieve a Menu Name by Menu Location with ACF fields
- Woocommerce Disabling Auto Restocking for Cancelled Orders
- Display shipping class in single product page woocommerce
- Editing product categories suddenly crashes website and goes back to wordpress installation
- ACF in WooCommerce mail template
- Woocommerce – Add custom email footer to specific email template
- WooCommerce related product – only show from primary category
- Merge “description” and “additional informations” product tab
- I need to refresh the checkout page if someone changes the zip code
- Correct method of reducing the number of images created by WP and Woo together
- add_filter not works in ajax
- How to skip woocommerce checkout after payment page? [closed]
- Product thumbnail size in catalog
- how can i import the csv file in wordpress woocommerce.?
- some products free and some product is not free for shipping
- Change wp-login.php? Problem with .htaccess password protection and multi user shop
- Conditional email recipient based off Shipping Method [closed]
- Save Woocomerce discount as percentage to database
- How to bypass Woocommerce checkout validation from the plugin? [closed]
- Custom product loop avoiding duplicates
- Woocommerce – Remove ‘Buy Product’ Button + Make Product Thumbnails Clickable
- Issue with Woocommerce and extra field in orders data
- How to show detailed order history on woocommerce product page [closed]
- Making product image in woocommerce invoice linkable [closed]
- registration_errors not working
- Translate Woocommerce tab
- Woocommerce -> gallery images per variation without a plugin? [closed]
- Why is my WordPress admin not working
- Create bookings after subscription renewal
- Hook for Woocommerce checkout fields