WooCommerce: Hide Products @ Shop Page |
您所在的位置:网站首页 › woocommerce remove sorting dropdown › WooCommerce: Hide Products @ Shop Page |
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 “default” product loop. Here’s what I did. ![]() 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 once 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 6 * @community https://businessbloomer.com/club/ */ 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' ); } |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |