×
Black Friday Savings
00Days
:
08Hours
:
32Minutes
:
37Seconds
Use Coupon 40%OFF

Includes 1 Year Priority Support

Shop Now

WP SITES

3093 Coded Tutorials & 296 Plugins

Redirect WooCommerce Shop Page Using Code

This PHP code, added to your child themes functions file, enables you to redirect your shop page to any URL you like.

In this case, we use 2 examples to demonstrate how to use the code.

The 1st code snippet redirects your shop page to your home page.

add_action( 'template_redirect', 'wpsites_redirect_shop' );
function wpsites_redirect_shop() {
    if ( is_shop() ) {
      wp_redirect( home_url()); 
	  exit;
    }
}

The 2nd code snippet redirects your shop page to an external URL.

add_action( 'template_redirect', 'wpsites_redirect_shop' );
function wpsites_redirect_shop() {
    if ( is_shop() ) {
wp_redirect('https://www.example.com/', 301 ); 
	  exit;
    }
}

= Related Solutions =

Was this helpful?

Yes
No
Thanks for your feedback!

Leave a Reply