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 →
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.