Create Custom Menu in WordPress Dashboard
Complete tutorial on create custom menu in wordpress dashboard. Discover practical examples, implementation tips, and expert advice for WordPress and WooCo
Read More βManaging a large catalog often requires hiding specific items from the main shop pageβwhether they are seasonal items, members-only products, or components of a bundle. While WooCommerce offers basic visibility settings, using Advanced Custom Fields (ACF) provides a much more intuitive workflow for site managers. By adding a simple "True/False" toggle to your product editor, you can programmatically alter the main shop query to skip products flagged for hiding, keeping your storefront organized without deleting inventory.
Looking to hide WooCommerce products using ACF custom field values? With a small tweak to your product query, you can control visibility via your custom fields.
Step 1: Required Plugins
Install these plugins before starting:
hide_product field to products.Step 2: Add the ACF Field
Here’s how to configure the field in ACF:
hide_product.Step 3: Filter the Product Query
Add the following code to your functions.php file:
function hide_products_with_acf_flag($query)
{
if (!is_admin() && is_shop()) {
$meta_query = $query->get('meta_query');
$meta_query[] = array(
'key' => 'hide_product',
'value' => '1',
'compare' => '!=',
);
$query->set('meta_query', $meta_query);
}
}
add_action('woocommerce_product_query', 'hide_products_with_acf_flag');
Step 4: Test Product Visibility
Mark any product with the hide_product field as true, and it will be excluded from the shop page listings.
Step 5: Add More Field Conditions
Want to filter based on multiple ACF fields? Use this enhanced version:
function hide_products_with_multiple_acf_conditions($query)
{
if (!is_admin() && is_post_type_archive('product') && $query->is_main_query()) {
$meta_query = $query->get('meta_query');
$meta_query[] = array(
'key' => 'hide_product',
'value' => '1',
'compare' => '!=',
);
$meta_query[] = array(
'key' => 'custom_flag',
'value' => 'yes',
'compare' => '=',
);
$meta_query['relation'] = 'OR';
$query->set('meta_query', $meta_query);
}
}
add_action('woocommerce_product_query', 'hide_products_with_multiple_acf_conditions');
Conclusion
Using ACF and a few lines of PHP, you can filter WooCommerce products dynamically. Perfect for seasonal or membership-based product visibility management.
Helpful Links:

Search our archives or reach out to our team for solutions and expert advice.