I want to hide any category pages
and the main shop page
So I need to redirect from category links and shop page to the root of the website
I use the code below for this, but it does more or less the opposite. any advice?
add_action( 'template_redirect', 'redirect_to_shop');
function redirect_to_shop() {
// Only on product category archive pages (redirect to shop)
if ( is_product_category() ) {
wp_redirect( wc_get_page_permalink( 'shop' ) );
exit();
}
}
2
Answers
You can use is_shop() and home_url()
So you get:
Try this:
You can use the following functions: