Remove "No products found" from a specific product category in Woocommerce

Александра Кузнецова

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' );
    }
}
LoicTheAztec

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)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Woocommerce - remove product from category

Display products from specific product category in Woocommerce

Remove add cart button in Woocommerce for a specific product category

Remove specific product variation from cart in WooCommerce

WooCommerce - Remove product title from breadcrumbs but keep all category hyperlinks

If product category has children remove permalink from parent term in WooCommerce

Hide “remove item” from cart for WooCommerce product category

Remove product category titles from shop page woocommerce

Exclude specific product ids from a category price suffix change in WooCommerce

Replace Upsells with products from a specific product category in Woocommerce 3

Disable other product categories for a cart item from specific category in Woocommerce

Send email if woocommerce order has items from a specific product category

Set a minimum quantity for cart items from specific WooCommerce product category

Check if a product belongs to a specific product category in Woocommerce

Remove specific product from WooCommerce cart only on a specific page

How to remove cart items from WooCommerce Session for a specific category

Remove product category placeholder image in Woocommerce

Target specific product category and it's children in WooCommerce

Woocommerce specific banner product category and childs

Add Custom field to woocommerce product for an specific category

Woocommerce - get product in category with specific attribute

Hide products having a specific product category in Woocommerce

WooCommerce checkout message based on specific product category

Hide attribute dropdown for a specific WooCommerce product category

Woocommerce Category Specific Code on Product Page

Add a custom button for a specific product category in Woocommerce

Add a fee for a specific product category in Woocommerce

Output a custom shortcode for a specific product category in WooCommerce

WooCommerce specific coupon discount based on product category