Reputation: 128
I have an issue with WooCommerce. I want to disable the shop page completely, but I still want users to be able to search for products.
This is what I have now - it works, but it also disables the search page, as this uses the shop page.
function woocommerce_disable_shop_page() {
global $post;
if (is_shop()):
global $wp_query;
$wp_query->set_404();
status_header(404);
endif;
}
add_action( 'wp', 'woocommerce_disable_shop_page' );
Hope you can help.
Upvotes: 0
Views: 1945
Reputation: 909
I just modified code in your question & it is working. Please add below code in theme's functions.php
file or custom plugin file.
function woocommerce_disable_shop_page() {
global $post;
if (is_shop() && !(is_search())):
global $wp_query;
$wp_query->set_404();
status_header(404);
endif;
}
add_action( 'wp', 'woocommerce_disable_shop_page' );
Upvotes: 3