// Snippet 2 /** * @snippet Remove Product Loop @ WooCommerce Shop * @how-to Get CustomizeWoo.com FREE * @author Rodolfo Melogli * @compatible WooCommerce 6 * @donate $9 https://businessbloomer.com/bloomer-armada/ */ add_action( 'pre_get_posts', 'bbloomer_remove_products_from_shop_page' ); function bbloomer_remove_products_from_shop_page( $q ) { if ( ! $q->is_main_query() ) return; if ( ! $q->is_post_type_archive() ) return; if ( ! is_admin() && is_shop() ) { $q->set( 'post__in', array(0) ); } remove_action( 'pre_get_posts', 'bbloomer_remove_products_from_shop_page' ); } /** * @snippet Remove "No products were found matching your selection" * @how-to Get CustomizeWoo.com FREE * @author Rodolfo Melogli * @compatible WooCommerce 6 * @donate $9 https://businessbloomer.com/bloomer-armada/ */ remove_action( 'woocommerce_no_products_found', 'wc_no_products_found' ); /** * @snippet 4 Products Per Category @ WooCommerce Shop * @how-to Get CustomizeWoo.com FREE * @author Rodolfo Melogli * @compatible WooCommerce 6 * @donate $9 https://businessbloomer.com/bloomer-armada/ */ add_action( 'woocommerce_no_products_found', 'bbloomer_show_4_products_per_category' ); function bbloomer_show_4_products_per_category() { $args = array( 'parent' => 0, 'hide_empty' => true, 'taxonomy' => 'product_cat', 'fields' => 'slugs', ); $categories = get_categories( $args ); foreach ( $categories as $category_slug ) { $term_object = get_term_by( 'slug', $category_slug , 'product_cat' ); echo '<hr><h2>' . $term_object->name . '</h2>'; echo do_shortcode( '[products limit="4" columns="4" category="' . $category_slug . '"]' ); echo '<p><a href="' . get_term_link( $category_slug, 'product_cat' ) . '">View all ' . $term_object->name . ' products →</a>'; } }