Do you want to hide all products from the shop page in your WooCommerce store? Are you running something like a B2B/wholesale or members-only store and you do not want every single product available to the public? This post will show you two methods that you can use to hide all products on the shop page.
The first one involves a developer-friendly method that involves the use of a filter and hook. The other method is built-in in the WordPress core and I will share it in this post. With all that said, let us look into the two ways you can employ to hide all WooCommerce products from the shop page.
a) Steps to Add a PHP Snippet to Hide All Products WooCommerce Shop Page
To do this, you need to follow these simple steps.
- Log into your WordPress site and access the Dashboard as the admin user.
- From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file where we will add the function that will add a function to hide all products at the WooCommerce shop page.
- Add the following code to the php file:
/** * @snippet Remove Product Loop @ WooCommerce Shop */ add_action( 'pre_get_posts', 'njengah_remove_products_from_shop_page' ); function njengah_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', 'njengah_remove_products_from_shop_page' ); }
- To remove the ‘No products were found matching your selection’ simply add this line of code at the end of the php file.
/** * @snippet Remove "No products were found matching your selection" @ WooCommerce Loop Pages */ remove_action( 'woocommerce_no_products_found', 'wc_no_products_found' );
How the code works.
In the code above, the ‘pre_get_posts
‘, ‘njengah_remove_products_from_shop_page
‘ action that will target the shop page. To remove the products, I created a function that will remove the products, aided by a series of loops and a remove action.
b) Steps to hide Products from Displaying in Shop Page WooCommerce
There is nothing much to discuss this. This simple solution took me a long time to find but it will help you hide a particular product form displaying from your WooCommerce shop page but still have it published here’s the trick:
- Log into your WordPress site and access the Dashboard as the admin user.
- From the Dashboard menu, click on Products > All Products. This will open all the products in your WooCommerce store and you need to open the details of the product that you want to hide and click on Edit.
- On the right side of the screen, you will see the Catalog visibility and you need to click on edit as shown below:
- After clicking on Edit, a set of options will appear with checkboxes which will allow you to hide the product as shown below:
You can preview the changes that you make or you can click on OK and update to publish the changes that you have made.
- To see the outcome you need to refresh the Shop page and that particular product will not appear on the Shop page.
It is however important to note that this will only work for particular products, not all of the products. This could be a solution if you only want to hide particular products, which you select and hide, following the simple steps above.
Conclusion
In this post, I have highlighted two methods that you can use to hide products in your WooCommerce Shop page. The first method is a developer-friendly method of using a PHP code snippet and the second one involves hiding a particular product. However, if you want to hide many products, it is much more efficient to just bulk assign them to a category and hide that category using the next method.
Similar Articles
- 30+ Best WooCommerce Plugins for Your Store (Most are FREE)
- Hide or Remove the Quantity Field from WooCommerce Product Page
- WooCommerce Redirect after Checkout : How to Automatically Redirect to a Custom Page After Checkout
- How to Remove Related Products in WooCommerce in 3 Easy Options
- 23 Best WooCommerce Plugins for Checkout Page Customization
- How to Remove the Billing Details from WooCommerce Checkout
- How to Hide a Product in WooCommerce or Hide Products by Category or Roles
- How to Add Remove Icon to WooCommerce Checkout Page
- How to Remove Default Product Sorting WooCommerce
- How to Display WooCommerce Products By Category
- How to Hide the WooCommerce Coupon Code Field
- How to Sell Digital Products With WooCommerce
- How to Sort WooCommerce Categories for Better User Experience
- How to Get Order ID In Woocommerce
- How to Change Shop Page URL in WooCommerce Quickly
- How to Get Post ID by Slug in WordPress With a Practical Example
- How to Set Featured Products In WooCommerce
- How to Hide the WordPress Admin Bar Programmatically Without Plugin
- 5+ Ways to Remove Sidebar from Product Page in WooCommerce Themes
- How to Check If Plugin is Active In WordPress [ 3 WAYS ]
Comments are closed.