Searching for fields created with Advanced Custom Fields ( ACF ) plugin.
Advanced Woo Search PRO plugin version comes with full support for Advanced Custom Fields ( ACF ) fields.
All ACF plugin fields content can be available for search and will display products related to these fields.
Also you can display any of the custom fields right inside the search results box and create search results filters based on any ACF field.
Enable the search for any products custom fields created via ACF plugin.
Plugin supports all fields types of ACF plugin: Text, Text Area, Number, Email, URL, Wysiwyg Editor, Link, Post Object, Page Link, Relationship, Taxonomy, User.
If any of these fields insert inside layout fields like Group, Repeater or Flexible Content AWS plugin will also find them.
To enable support for ACF fields search first of all it is needed to activate Custom fields search source from the plugin search page.
Then click on the gear icon near it. You will see the list of all available custom fields of your site. All of them are disabled for search by default. You need to find here ACF fields then must be searchable and activate them.
After you do this all content that was generated via enabled ACF fields will be available for search.
It is possible to display any ACF custom fields right inside products' AJAX search results. You can display any type of custom field that the ACF plugin provides.
To display such fields you need to use some custom code snippets. These snippets need to be placed somewhere outside the plugins folder. The best way is to use some plugin for adding code snippets ( for example, this one ). Or just place the code inside your theme functions.php
file.
Example: with the ACF plugin we created a new custom field Product Num
of type Text
.
So to display this custom field for any product inside search results that has not empty value for it just use the following code snippet:
add_filter( 'aws_excerpt_search_result', 'my_aws_excerpt_search_result', 10, 2 ); function my_aws_excerpt_search_result( $excerpt, $post_id ) { $field_name = 'product_num'; if ( function_exists( 'get_field' ) ) { $field = get_field( $field_name, $post_id ); if ( $field ) { $excerpt = $excerpt . '<br>' . '<span style="margin-top:3px;display:block;color:#000;font-size:11px;font-weight:bold;">Product Num : ' . $field . '</span>'; } } return $excerpt; }
So after adding this code product search results with field product_num
will display it inside AJAX results.
Create products search results filter based on any available ACF field. With such filters you can show/hide products based on custom fields values.
Steps to create a filter:
1. Open the plugin settings page -> Search Results tab and scroll down to Filter Results section.
2. Click on Filter products search results
button to create a new filter rule.
3. Set following filter rule:
ACF: Fields -> {Field_NAME} -> equal to -> {Field_Value}
So you need to choose a custom field name and field value for the filter rule. Also choose from equal to
and not equal to
operators.
4. Just click on Save Changes button and your newly created filters are ready. Just check the plugin search form to make sure that all is working as should.
Below we will cover different types of ACF fields and how to use them relative to the Advanced Woo Search plugin.
For example, you created text field type.
And you have a product called T-Shirt with Logo
. So for this product you set ACF text field value to, for example, some custom text
.
Right after you save this product with this custom field content it will be available for search ( of course if you enable this field from the plugin settings page ).
Another example - with link relational field. This field type gives the option to create link relations with any other page or post type.
We will edit this field for T-Shirt with Logo
product. For example, let's create a link to another product that is called Hoodie with Zipper
.
So now when searching for Hoodie with Zipper
search results will show not only this product itself but and T-Shirt with Logo
.
Post object field gives the option to attach any custom post type to any other one.
In our example we will attach to T-Shirt with Logo
product a V-Neck T-Shirt
product.
Now when searching for V-Neck T-Shirt
search results will show not only this product itself but and T-Shirt with Logo
.
This field type gives the option to attach a link to any page or post type.
Lets attached to T-Shirt with Logo
product Hoodie with Pocket
product.
Now when searching for Hoodie with Pocket
search results will show not only this product itself but and T-Shirt with Logo
.
Relationship field gives the option to create a relationship between two posts.
Lets create a relation between T-Shirt with Logo
product and Checkout
page.
Now when searching for Checkout
page search results will show T-Shirt with Logo
product.
With taxonomy field it is possible to attach any WordPress taxonomy to your WooCommerce product.
For example, let's attach to product T-Shirt with Logo
product category taxonomy terms Clothing
and Tshirts
.
Now when searching for Clothing
or Tshirts
we will see T-Shirt with Logo
product in search results.
With user field type it is possible to attach any user to your product.
Lets add user wooteam
to T-Shirt with Logo
product.
Now when searching for wooteam
user we will see T-Shirt with Logo
product in search results.
Grouped fields gives the option to combine several fields together. All ACF plugin fields that were added inside the field group will be available for search as usual fields ( Text, Text Area, Number, Email, URL, Wysiwyg Editor, Link, Post Object, Page Link, Relationship, Taxonomy, User ).
For example, lets create new fiel group with text
and textarea
fields inside.
Than lets add some content for this fields to T-Shirt with Logo
product.
Now when searching for any of this custom content we will see T-Shirt with Logo
product in search results.
Repeater allows to create unlimited number of pre-defined fields groups inside the product.
For example, lets create repeater with text and textarea fields inside.
Than lets add some content for this fields to T-Shirt with Logo
product.
Now when searching for any of this custom content we will see T-Shirt with Logo
product in search results.