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?
Thanks for your feedback!

Leave a Reply
You must be logged in to post a comment.