How to Search Grid Terms from a Taxonomy Using JetSmartFilters: A Complete Guide
If you’re looking to implement a dynamic search filter for taxonomy terms in your WordPress site using JetSmartFilters, this step-by-step guide will help you set it up seamlessly with JetEngine Query Builder. With some custom code and proper configuration, you can create a fully functional search system that allows users to filter by category titles or taxonomy terms.
With JetSmartFilters and JetEngine, you can unlock powerful features for filtering content dynamically. Let’s dive into the process.
Step 1: Add Custom Code to Your WordPress Site
To enable taxonomy term searches, you first need to add custom PHP code. You can add this code to the functions.php file of your child theme or use a plugin like Code Snippets to insert the snippet.
Code Snippet Link:
https://gist.github.com/LaxusCroco/dae76a0cec6830eb029e280d9325a386#file-search_terms_by_names-php
OR COPY FROM HERE
<?php
add_filter( 'jet-smart-filters/query/final-query', function($query){
if( isset( $query['meta_query'] ) ){
foreach( $query['meta_query'] as $item => $value){
if( $value['key'] === '_search_by_term_name' ){
$query['search'] = $value['value'];
unset($query['meta_query'][$item]);
}
}
}
return $query;
});
This code is essential for enabling the filter to search by taxonomy term name.
Step 2: Configure the Search Filter in JetSmartFilters
To configure the search filter to work with taxonomy term names:
- Open the JetSmartFilters settings in your WordPress Dashboard.
- Select “By Custom Field” as the search method.
- Add the following Query Variable: _search_by_term_name
Reference Screenshot:
https://prnt.sc/DOWgZEudNun6
This setup allows your search field to look for matches in taxonomy term titles.
Step 3: Create a Terms Query with JetEngine Query Builder
To ensure the search filter works, create a Terms Query in the JetEngine Query Builder.
- Go to WordPress Dashboard > JetEngine > Query Builder.
- Create a new query and select Terms Query.
- Choose the taxonomy (like category, tag, or custom taxonomy) that you want to include in the search.
- Save the query.
If you don’t need additional filters, the default setup will suffice.
Example Screenshot:
https://prnt.sc/FUk-an-7pquT
Detailed Tutorial:
https://crocoblock.com/knowledge-base/articles/jetengine-query-builder-terms-query-overview/
Step 4: Apply the Query to the Taxonomy Listing
Once the query is created, you need to assign it to the taxonomy listing.
- Open the listing grid where you display the taxonomy terms.
- Assign the newly created query to the listing.
Screenshot Reference:
https://prnt.sc/Z61lfW6VVC1X
Without linking the query to the listing, the search filter won’t function as expected.
Step 5: Link the CSS ID and Query ID
To finalize the setup:
- Add a CSS ID to the Listing Grid. Assign a unique CSS ID to your listing grid for better identification.
Example Screenshot: https://prnt.sc/MfGizYSFzxZN - Use the same Query ID for the Filter and Query. Apply the same Query ID to both the filter and the query to link them together.
Filter Setup Screenshot: https://prnt.sc/e2iP5fTTG2kA
Query Setup Screenshot: https://prnt.sc/TXOPC0YX9a3u
If you have multiple queries on the same page, ensure that each query has a unique Query ID to avoid conflicts, such as naming them never-filter, product-filter, etc.
Why Is a Custom Query Important?
A custom query ensures that the search filter pulls data from the correct taxonomy and displays results in your listing grid. Without this, the search filter won’t work correctly.
Final Thoughts
By following these steps, you’ll have a fully functional taxonomy term search filter integrated with JetSmartFilters and JetEngine. This is perfect for websites with large amounts of content categorized under custom taxonomies, allowing users to find information quickly and efficiently.
Whether you’re building a blog, eCommerce store, or listing site, this feature significantly enhances the user experience.
Keywords:
JetSmartFilters taxonomy search, WordPress filter by taxonomy, JetEngine Query Builder, taxonomy term search, JetSmartFilters custom query, WordPress dynamic filters, JetEngine terms query tutorial, WordPress search filter setup.