Are you looking for the best and quickest way to remove product categories from URL WoocCommerce without a plugin?
In this post, I want to show you how you can get rid of the category from the product URL without breaking your site or losing SEO significance.
Most WooCommerce store owners are struggling with this issue and would like to figure out how to remove product categories from URL WooCommerce without plugins and without losing the SEO ranking or ending up with hundreds of 404 page not found errors.
Table of Contents
Remove Product Category from URL WooCommerce Without Plugin
First, you need to figure out how the WordPress URLs work.
The URLs in WordPress are technically referred to as permalinks and this is important as you remove product categories from URL WooCommerce without a plugin.
You can access the WordPress permalinks under the settings menu and a child menu or sub-menu – Permalinks.
In my previous tutorial on how to remove Index.php from WordPress URL, I illustrated how permalinks should be set up immediately after installing WordPress.
The tutorial can be a good place to begin understanding how permalinks work in WordPress.
There is not much difference between WooCommerce and WordPress when it comes to permalinks since WooCommerce URLs use the same WordPress permalink structure.
Settings to Remove Product Category from URL WooCommerce Without Plugin
When you look at the settings for the WooCommerce permalinks you can see them as shown in the image below :

We can change this by updating the permalinks to the shop base option as shown in the image below and the same will be updated in the URL structure in the front. This is the quickest way to remove this slug from the URL of the product.
You can see the results after you update the permalink structure as shown in the image below :
Code to Remove Product Category from URL WooCommerce Without Plugin
Another option we can use code to remove the URL product category slug and it will work just like the settings option works.
This can be a useful way for developers who want to implement this in their plugin development especially when creating a WooCommerce redirect plugin like the most popular WooCommerce redirect after checkout plugin.
You can the code snippet below to the functions.php of your custom theme or for your WooCommerce child theme and this should do the trick to remove the product category from URL WooCommerce without a plugin:
add_filter('request', function( $vars ) { global $wpdb; if( ! empty( $vars['pagename'] ) || ! empty( $vars['category_name'] ) || ! empty( $vars['name'] ) || ! empty( $vars['attachment'] ) ) { $slug = ! empty( $vars['pagename'] ) ? $vars['pagename'] : ( ! empty( $vars['name'] ) ? $vars['name'] : ( !empty( $vars['category_name'] ) ? $vars['category_name'] : $vars['attachment'] ) ); $exists = $wpdb->get_var( $wpdb->prepare( "SELECT t.term_id FROM $wpdb->terms t LEFT JOIN $wpdb->term_taxonomy tt ON tt.term_id = t.term_id WHERE tt.taxonomy = 'product_cat' AND t.slug = %s" ,array( $slug ))); if( $exists ){ $old_vars = $vars; $vars = array('product_cat' => $slug ); if ( !empty( $old_vars['paged'] ) || !empty( $old_vars['page'] ) ) $vars['paged'] = ! empty( $old_vars['paged'] ) ? $old_vars['paged'] : $old_vars['page']; if ( !empty( $old_vars['orderby'] ) ) $vars['orderby'] = $old_vars['orderby']; if ( !empty( $old_vars['order'] ) ) $vars['order'] = $old_vars['order']; } } return $vars; });
Conclusion
In this post, we have outlined the two ways you can employ to remove product categories from URL WooCommerce without a plugin.
Using the settings update is the easiest way and can be a good option for nontechie WooCommerce users.

Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
More articles written by Joe
Similar Articles
- How to Display All Products With No Weight WooCommerce
- How to Add Google Analytics to WooCommerce
- How to Add Product SKU In WooCommerce
- How to Remove Product Image Placeholder In WooCommerce
- How to Set WooCommerce Related Products Same Category
- How to Upload Image On Product Page In WooCommerce
- How to Customize WooCommerce Order Received Page
- How to Force Maximum 1 Category Per Product WooCommerce
- How to Remove Product Category Title WooCommerce
- How to Change Return to Shop Link in Woocommerce
- How to Delete a Category in WordPress
- How to Change Out Of Stock Text in WooCommerce
- How to Create WooCommerce Storefront Child Theme [Complete Guide]
- How to Redirect User If Not Logged in WordPress » Page Redirect
- How to Add Text after Price in WooCommerce » Add Price Suffix
- How to Remove Phone Number Field From Checkout WooCommerce
- How to Add or Remove Icons to WooCommerce Checkout Page