In this tutorial I’m going to show You how to create a dropdown filter with AJAX for WordPress Categories.
Step #1 – Filter by taxonomy terms
Create a file named dropdown-filter.php
/your-child-theme/ajax-dropdown/dropdown-filter.php
Search and replace “YOUR_TAXONOMY” and “YOUR_POST_TYPE” in following the code!
#3 'taxonomy' => 'YOUR_TAXONOMY' #20 'post_type' => 'YOUR_POST_TYPE',
Step #2 – Create a shortcode and place it wherever You want
Just copy this code in the functions.php
Step #3 – Send a Request and to Receive Result Data
Create a file named dropdown-filter.js
Step #4 – Process the Request
Copy this snippet in functions.php
Search and replace “YOUR_TAXONOMY” in the code: #16th line
'taxonomy' => 'YOUR_TAXONOMY',
candy says
Thank you so much…
it helped me alot
Jason Hunter says
How can I change what is shown once the “Apply Filter” button is pressed? Right now it is only showing me the title, but I would like to show the title, excerpt and a ‘Read More’ button.
Thanks.
Jason Hunter says
Nevermind I found it.
yellow kite says
If I need to use the filter with a custom post type and a taxonomy, how can I do it?
Gabor Flamich says
Hi, I updated the tutorial, tested and it works with CPT.