Overview
Advanced Custom Fields (ACF) is one of the most popular WordPress plugins used by developers to add custom fields to posts, pages, and products. Its flexibility and ease of use have made it a go-to tool for tailoring WordPress sites to specific needs.
As WooCommerce stores grow and product catalogs expand, store owners face an increasing demand for more refined and precise search capabilities. Default WooCommerce search is limited, often returning too many or irrelevant results. That's where we can use acf filters and advanced custom fields filters to limit search results only to needed products and make users' search queries more relevant.
In this article, we’ll show you how to create WooCommerce search results filters based on ACF fields using both custom code and the Advanced Woo Search plugin.
As an example, we will create a is_searchable
boolean ACF field and show in product search results only products with that field value set to 1
.
Why Use ACF for WooCommerce Filtering
Out of the box, the WooCommerce search results page returns all products that match the current search query.
But what if you need to limit those search results by a specific parameter?
This is where ACF comes in. With ACF, you can attach custom fields to WooCommerce products - whether it’s text fields, dropdowns, checkboxes, or even repeaters. These custom fields open the door to acf woocommerce filters and advanced custom fields search filters that truly reflect your store’s unique catalog.
Real-world use cases include:
- Filtering clothing by color and size
- Searching electronics by brand or technical specs
- Browsing furniture by material or collection
Ways to Filter Search Results by ACF Fields
To enable filtering by ACF fields, there are two main approaches:
- Writing custom code
- Using the Advanced Woo Search (AWS) plugin
Advanced Woo Search plugin is a powerful tool that allows you to enhance WooCommerce search with support for ACF, custom taxonomies, product metadata, and more - all without writing code.
In this article, we’ll cover both ways of limiting search results by ACF fields and compare them in the end.
Filtering Search Results by ACF Fields with Custom Code
First, let's cover how to filter search results by an ACF field using a custom code snippet.
Example: Filter by is_searchable
field created via ACF plugin.
To implement this logic, use the following code snippet:
add_action('pre_get_posts', 'filter_woocommerce_search_by_custom_field'); function filter_woocommerce_search_by_custom_field($query) { if (!is_admin() && $query->is_main_query() && $query->is_search() && is_woocommerce()) { $meta_query = array( array( 'key' => 'is_searchable', 'value' => '1', 'compare' => '=' ) ); $query->set('meta_query', $meta_query); } }
Add this code somewhere outside the plugins folder, for example, inside the functions.php
file of your theme, or use a plugin for adding code snippets.
This approach works but has limitations. What if you need to add additional logic, like another ACF field or a different comparison operator? Or what if you want to apply this rule only for certain customer groups? Adding all those parameters will quickly make the code large and unreadable.
It also requires coding knowledge and lacks a user-friendly interface. For most store owners, a plugin solution is far more efficient and flexible.
Filtering Search Results by ACF Fields with AWS Plugin
For almost anyone, the simplest yet most powerful way to create search result filters based on an ACF field is to use the Advanced Woo Search plugin.
The Advanced Woo Search plugin makes it simple to set up acf search filters without any coding. Here’s how you can do it:
- Install and activate the AWS plugin.
- Reindex the plugin table by clicking the Reindex table button inside the settings page. This action only needs to be done once.
- Go to Adv. Woo Search -> Search Results page in your WordPress dashboard. Scroll down to the Filter Results section.
- Click on the Filter products search results button to create a new filter for product search results.
- Set the following new search results filter:
ACF:Fields -> is searchable -> equal to -> 1
- Now just save all your changes and check the search results - they will now only show products where the ACF field
is_searchable
is set to1
.
This setup lets customers refine results using acf filter by custom field, creating a much more powerful and intuitive shopping experience.
Bonus: Filtering Search Results by ACF Taxonomy with AWS Plugin
If you’re using ACF to create custom taxonomies (like “Collection”, “Theme”, or “Designer”), AWS can handle that too.
Example: Filtering by "Collection" taxonomy created via ACF plugin
- In ACF, create a custom taxonomy called Collection and assign it to products.
- Go to Products -> Collection taxonomy page and add some new terms for it like “Spring 2025”, “Luxury Line”, or “Eco Series”.
- Go to Adv. Woo Search -> Search Results page in your WordPress dashboard. Scroll down to the Filter Results section.
- Click on the Filter products search results button to create a new filter for product search results.
- Set the following new search results filter:
Product taxonomy -> Collection -> equal to -> {taxonomy term}
where {taxonomy term} is the desired Collection taxonomy term. Or set it toAny
to show all products that have any term related to the Collection taxonomy. - Save the options and check your search results - you will now see only WooCommerce product search results that have the required Collection taxonomy terms.
Now, customers can filter search results using an acf taxonomy filter, enhancing both usability and conversion rates.
Conclusion
Combining ACF with the Advanced Woo Search plugin is one of the most effective ways to implement powerful WooCommerce search filtering. Whether you're dealing with custom fields or taxonomies, AWS gives you full control over how products are found and displayed.
By using acf filters, you can dramatically improve product discoverability and help customers find exactly what they’re looking for - boosting both satisfaction and sales.
You can use some custom code snippets to limit product search results by ACF field, but it is a very limited approach and requires some coding knowledge.
Feature | Custom Code | Advanced Woo Search (AWS) Plugin |
---|---|---|
Ease of Use | Requires PHP knowledge and manual setup | User-friendly interface, no coding needed |
Setup Time | Longer - manual coding and testing required | Faster - mostly point-and-click configuration |
Custom Field Support | Yes, with proper meta query setup | Yes, built-in support for ACF fields |
Taxonomy Filtering | Possible, but requires more complex code | Yes, easy setup via UI |
Filter UI Display | Requires custom theme modifications | Built-in filter display options (dropdowns, checkboxes, etc.) |
Scalability | Good, but maintenance can become difficult | Excellent, easily managed through dashboard |
Flexibility | Highly flexible for developers | Flexible and extendable via plugin settings |
Best For | Experienced developers who want full control | Store owners and non-developers seeking quick results |
FAQ
- What is the Advanced Custom Fields (ACF) plugin?
- ACF is a very popular WordPress plugin used to create and manage custom fields.
- Can I search for WooCommerce products by ACF fields?
- Yes. With the Advanced Woo Search plugin, you can search for products via ACF fields. You just need to set it up correctly.
- What ACF field types does the Advanced Woo Search plugin support?
- The AWS plugin supports all ACF field types that return readable output - including text, textarea, number, email, URL, image, select, checkbox, radio button, true/false, and more.
- Is it possible to filter by ACF taxonomies?
- Absolutely. ACF taxonomies can be used as filtering values for AWS plugin search results.
- Do I need to code to use ACF filters in search?
- No. Plugins like Advanced Woo Search allow you to configure this without writing any code.
- Can I search and display taxonomies created with the ACF plugin?
- Yes, it is possible. You just need to enable search for the specific taxonomy.
- Which plugin supports ACF search filtering best?
- Advanced Woo Search is one of the most comprehensive plugins for adding ACF taxonomy filter and advanced custom fields search filter functionality to WooCommerce.
Comments