A client wanted to show only featured products on the shop page. While adding featured products is very easy (just use the WooCommerce shortcode in the page content), it seems very difficult to remove the “other” products. Here’s what I did.

WooCommerce Remove Loop at Shop PageWooCommerce Remove Loop at Shop Page
WooCommerce Remove Loop at Shop Page – the old way (commenting out core code). Thankfully there’s a better solution!

PHP snippet: Hide Products @ WooCommerce Shop Page

Please note: “Product Catalog” > “Shop page display” must be set to “Show products” in the WordPress > Appearance > Customizer > WooCommerce admin settings. Following snippet won’t work if you only have product categories @ product page.

To hide the “No products were found matching your selection” message that shows if the Shop page has no products to show, use this other snippet.

 * @snippet       Remove Product Loop @ WooCommerce Shop
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.5.7
 * @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' );

Leave a Reply