Redirect Woocommerce Multisite shop page to another URL

Here’s a snippet to switch a Multisite Woocommerce store from one store shop page to another.  Handy when you point your store Shop page to the main store from a subsite shop page.  You may have done this in the menu, but if you use breadcrumbs then this will still show the current site store page. This snippet added to the top of your PHP template file will redirect automatically to any URL you prefer.

$blog_id = get_current_blog_id();
if ( $blog_id == 2 ) { //  or any other site ID you prefer
if ( is_shop() ) {
wp_redirect( '/main-store', 301 );
exit;
}
}

Useful post? Share it

Leave a Reply

Your email address will not be published.