How To Remove Shop From Url Woocommerce

How to Remove “Shop” from Your WooCommerce URL: A Comprehensive Guide

Introduction:

Are you frustrated by the “/shop/” segment in your WooCommerce store’s URLs? Do you feel it’s unnecessary and detracts from a cleaner, more professional look? You’re not alone! Many WooCommerce store owners want to remove the “shop” base slug to create more user-friendly and SEO-optimized URLs. This article provides a step-by-step guide on how to achieve this, along with considerations and potential pitfalls. By the end, you’ll understand how to effectively remove “shop” from your WooCommerce URLs and improve your store’s overall structure.

Main Part: Removing the “/shop/” Slug

There are a few methods to remove the “/shop/” base from your WooCommerce URLs. We’ll explore the most common and reliable ones.

Method 1: Changing the Shop Base Category in WooCommerce Settings

This is the most straightforward and generally recommended method.

1. Log in to your WordPress Dashboard: Access your WordPress admin area by going to `yourdomain.com/wp-admin`.

2. Navigate to WooCommerce Settings: Go to `WooCommerce > Settings`.

3. Click on the “Products” Tab: This tab manages product-related settings.

4. Find the “Shop page” Setting: This setting is typically located under the “General display options” or “Product archives” section (the exact location can vary slightly depending on your WooCommerce version).

5. Select a Different Page (or Create a New One):

    • If you have another page you want to use as your shop page (e.g., your homepage), select it from the dropdown. Note: If you choose your homepage, all product archive links will now point to the homepage.
    • If you don’t have a suitable page, create a new page (e.g., named “Products” or “Store”) and then select it here.
    • 6. Save Changes: Click the “Save changes” button at the bottom of the page.

      7. Update Permalink Settings: Go to `Settings > Permalinks`. Select a permalink structure other than “Plain”. The recommended Check out this post: How To Export And Import Woocommerce Products structure is “Post name”. Crucially, click the “Save Changes” button again, even if you haven’t changed anything. This flushes the rewrite rules.

    Method 2: Using a Plugin

    Several plugins simplify the process of removing the “/shop/” slug. While these plugins can be convenient, it’s essential to choose a reputable and well-maintained plugin.

    1. Install and Activate a Plugin: Search for plugins like “Remove WooCommerce Shop Page Slug” or similar in the WordPress plugin repository. Ensure Explore this article on How To Set Default On Order Status Woocommerce the plugin has good reviews and is actively maintained.

    2. Configure the Plugin: Activate the plugin, and then find its settings page (usually under WooCommerce or Settings).

    3. Follow the Plugin’s Instructions: Most plugins will have a simple option to remove the “shop” slug. Follow the plugin’s instructions carefully.

    4. Update Permalink Settings (Important!): As with Method 1, go to `Settings > Permalinks` and click “Save Changes” to flush the rewrite rules.

    Method 3: Using Custom Code (Advanced – Use with Caution!)

    This method involves adding custom code to your `functions.php` file or a custom plugin. Incorrect code can break your website, so only proceed if you’re comfortable with PHP. It’s highly recommended to use a child theme when making changes to `functions.php`.

     /** 
  • Remove "shop" from WooCommerce URLs
  • */ add_filter( 'woocommerce_get_permalink', 'remove_shop_from_wc_permalink', 10, 2 ); function remove_shop_from_wc_permalink( $permalink, $product ) { $shop_page_id = wc_get_page_id( 'shop' ); $shop_page_slug = get_post_field( 'post_name', $shop_page_id ); if ( strpos( $permalink, '/' . $shop_page_slug . '/' ) !== false ) { $permalink = str_replace( '/' . $shop_page_slug . '/', '/', $permalink ); } return $permalink; }

    add_filter( ‘woocommerce_product_category_link’, ‘remove_shop_from_wc_product_category_link’, 10, 2 );

    function remove_shop_from_wc_product_category_link( $term_link, $term ) {

    $shop_page_id = wc_get_page_id( ‘shop’ );

    $shop_page_slug = get_post_field( Explore this article on How To Delete Reviews Woocommerce ‘post_name’, $shop_page_id );

    if ( strpos( $term_link, ‘/’ . $shop_page_slug . ‘/’ ) !== false ) {

    $term_link = str_replace( ‘/’ . $shop_page_slug . ‘/’, ‘/’, $term_link );

    }

    return $term_link;

    }

    add_filter( ‘request’, ‘woo_custom_shop_url’ );

    function woo_custom_shop_url( $query_vars ) {

    if( isset( $query_vars[‘page’] ) && ! empty( $query_vars[‘name’] ) ) {

    if( $query_vars[‘page’] == wc_get_page_id( ‘shop’ ) ) {

    unset( $query_vars[‘page’] );

    }

    }

    return $query_vars;

    }

    add_filter( ‘rewrite_rules_array’, ‘woo_rewrite_rules’ );

    function woo_rewrite_rules( $rules ) {

    $new_rules = array();

    $new_rules[‘(.+)/product-category/(.+)/?$’] = ‘index.php?product_cat=$matches[2]’;

    return $new_rules + $rules;

    }

    Important Considerations After Implementing Any Method:

    • Clear your browser cache and website cache: Caching can prevent changes from appearing immediately.
    • Test your URLs thoroughly: Click through your store to ensure all product links, category links, and other related URLs are working correctly. Pay close attention to pagination on category pages.
    • Implement 301 redirects (if necessary): If you’ve had your store running for a while, consider implementing 301 redirects from the old URLs (`/shop/product-name`) to the new URLs (`/product-name`). This helps maintain your SEO ranking. You can use a plugin like “Redirection” to easily manage redirects.

    Troubleshooting Common Issues:

    • 404 Errors: 404 errors are a common symptom of incorrect permalink settings. Ensure you’ve saved your permalink settings *after* making any changes to your WooCommerce settings or using a plugin. Try switching to the default WordPress theme temporarily to rule out theme conflicts.
    • Category Pages Not Working Correctly: If category pages are not displaying products or redirecting incorrectly, double-check your category base settings (WooCommerce > Settings > Products > Display) and that you’ve flushed the rewrite rules.

Conclusion:

Removing the “/shop/” segment from your WooCommerce URLs can improve your store’s aesthetics and potentially its SEO performance. While there are several methods, the simplest is usually changing the “Shop page” setting in WooCommerce. Remember to update your permalink settings afterward and thoroughly test your URLs. If you’re comfortable with code, the custom code method provides more control. By following these steps, you can achieve cleaner, more professional WooCommerce URLs and provide a better user experience for your customers. Always back up your site before making major changes!

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *