How to Hide Products From Your WooCommerce Shop Page (Without Deleting Them)
Introduction:
WooCommerce is a powerful and flexible e-commerce platform, but sometimes you need to manage your product visibility beyond simply publishing or unpublishing. Perhaps you want to offer a product only through a specific URL, or you need to temporarily remove an item from your main shop page without losing its data. This article will guide you through different methods on how to hide products from your WooCommerce shop page while keeping them accessible for other purposes. We’ll cover various techniques, from using the WooCommerce built-in settings to employing plugins and code snippets.
Main Part:
Hiding products from your shop page can be useful in several scenarios:
- Limited-time promotions: You might want to hide a product until a specific sale starts.
- Exclusive products: You might only want to offer a product via a direct link to VIP customers.
- Bundled deals: The individual components of a bundle might not need to be visible on the shop page.
- Out-of-stock management: Temporarily hiding a product while you restock can prevent customer frustration.
- Edit the Product: Go to Products > All Products in your WordPress dashboard and click on the product you want to hide.
- Find the “Publish” Meta Box: Locate the “Publish” box on the right-hand side of the screen.
- Edit Visibility: Click on the “Edit” link next to “Visibility.”
- Choose “Hidden” or “Catalog search”:
- Hidden: This makes the product invisible on the shop page, category pages, and search results. However, it’s still accessible if someone has the direct product URL.
- Catalog search: The product will be hidden from the shop page and category pages, but still visible in search results. This is useful if you want customers to find it through search but not browse to it.
- Update the Product: Click “OK” and then “Update” to save your changes.
- Create a “Hidden” Category: Go to Products > Categories and create a new category named “Hidden” or something similar. Don’t assign any products to this category yet.
- Hide the Category: Go to Appearance > Customize > WooCommerce > Product Catalog.
- Set Shop Page Display to “Show categories”: Choose “Show categories” from the “Shop page display” dropdown.
- Set Category Display to “Show products”: Choose “Show products” from the “Category display” dropdown.
- Exclude the “Hidden” Category: Most themes and page builders have options to exclude specific categories from being displayed on the shop page. Look for settings related to product display or category filtering.
- Assign Products to the “Hidden” Category: Now, go back and edit the products you want to hide and assign them to the “Hidden” category.
- WooCommerce Product Visibility: This type of plugin allows you to set visibility based on user roles, dates, and other criteria.
- Advanced Product Visibility Control: Offers more granular control over who can see specific products, based on membership levels, user groups, and more.
- Catalog Visibility Options: Provides options to hide products based on location, time, or user.
- Often more flexible than built-in settings.
- Can automate the hiding/showing process.
- May offer advanced features like hiding based on user role.
- Requires installing and configuring a plugin.
- Plugin compatibility issues can sometimes arise.
- Some plugins may be paid.
Let’s explore the ways to achieve this:
1. Using WooCommerce Visibility Settings
WooCommerce offers built-in visibility options for each product. This is often the simplest method.
This method is quick and easy, but it requires you to manually adjust the visibility for each product.
2. Using WooCommerce Product Categories
You can leverage product categories to selectively hide products.
This method allows you to control the visibility of multiple products at once, but relies on your theme or page builder having the necessary customization options.
3. Using WooCommerce Plugins
Several plugins offer advanced product visibility control. Here are a few examples:
Pros:
Cons:
4. Using Custom Code (Advanced)
For advanced users, you can use custom code to modify the WooCommerce query and exclude specific products from the shop page. This involves adding code to your theme’s `functions.php` file or using Check out this post: How To Send A Test Email Woocommerce a code snippets plugin.
Example Code:
add_action( 'pre_get_posts', 'exclude_products_from_shop' ); function exclude_products_from_shop( $query ) { if ( is_admin() || ! $query->is_main_query() ) { return; }
if ( is_shop() ) {
$query->set( ‘post__not_in’, array( 123, 456, 789 ) ); // Replace with the actual product IDs
}
}
Explanation:
- This code snippet uses the `pre_get_posts` action to modify the main query before it retrieves products.
- `is_shop()` checks if the current page is the shop page.
- `$query->set( ‘post__not_in’, array( 123, 456, 789 ) )` excludes products with IDs 123, 456, and 789 from the query. Replace these with the actual IDs of the products you want to hide.
Important: Always back up your website before making changes to your theme’s `functions.php` file. This method requires coding knowledge and can cause issues if not implemented correctly.
Conclusion:
There are several ways to hide products from your WooCommerce shop page without deleting them. The best method depends on your specific needs and technical expertise. Consider the simplicity of using WooCommerce’s built-in visibility settings, the category-based approach, the flexibility of plugins, or the power (and complexity) of custom code. Choose the approach that best suits your requirements and ensure you thoroughly test your changes to maintain a smooth shopping experience for your customers. Remember to always back up your website before making significant changes.