...

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:

  1. Open the JetSmartFilters settings in your WordPress Dashboard.
  2. Select “By Custom Field” as the search method.
  3. 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.

  1. Go to WordPress Dashboard > JetEngine > Query Builder.
  2. Create a new query and select Terms Query.
  3. Choose the taxonomy (like category, tag, or custom taxonomy) that you want to include in the search.
  4. 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.

  1. Open the listing grid where you display the taxonomy terms.
  2. 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:

  1. 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
  2. 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.

Enjoying the Tutorials? Show Your Support!

If you’ve found these WordPress tutorials helpful, consider supporting me with a small gesture of appreciation. A simple “Buy Me a Coffee” helps fuel my passion and keeps the tutorials coming! Your support makes a big difference and motivates me to create even more free content for you.

Seraphinite AcceleratorOptimized by Seraphinite Accelerator
Turns on site high speed to be attractive for people and search engines.