Reputation: 554
How do I delete a message "No products found" from a single category page? I tried various variations of the code below, but it did not work.
add_action( 'init','remove_woocommerce_no_products_found' );
function remove_woocommerce_no_products_found() {
if (is_product_category('name-page')) {
remove_action('woocommerce_no_products_found', 'action_woocommerce_no_products_found' );
}
}
Upvotes: 2
Views: 920
Reputation: 253919
You were very near… Try the following instead:
add_action( 'woocommerce_no_products_found','remove_wc_no_products_found', 1 );
function remove_wc_no_products_found() {
if ( is_product_category('witches') ) {
remove_action('woocommerce_no_products_found', 'wc_no_products_found' );
}
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
(Does not add the code in the template herself)
Upvotes: 2