WordPress Search & Filter is a simple search and filtering plugin. It is essentially an advancement of the WordPress search box, adding taxonomy filters & post filters to really refine your searches.
You can search by Category, Tag, Custom Taxonomy, Post Type or any combination of these easily – you can even remove the search box and simply use it as a filtering system for your posts and pages.
After my own requirements of needing some granular filters applied to my searches I tried a few free plugins online and found none quite did what I need, there are many plugins that enhance the search box, and there are others that allow filtering of taxonomies but none that combine the two and are free (as far as I can tell).
The best free plugin I found was the Query Multiple Taxonomies Plugin – however it did not allow you to search at the same time as applying the filters.
And so the Search & Filter plugin was born:
Download Wordpress Search & Filter
Grab the download any of these sources:
How To Use
To display Search & Filter all you need to do is a use a shortcode:
[searchandfilter fields="search,category,post_tag"]
This will display a search box, a category dropdown and a tag dropdown. You can use the shortcode within posts/pages and widget areas.
To use this within a theme file you simple need to call the `do_shorcode` function with the shortcode above within the theme file:
<?php echo do_shortcode( '[searchandfilter fields="search,category,post_tag"]' ); ?>
Documentation
Official documentation can be found on our docs site which contains usage examples and advanced settings & features.
Screenshots
[metaslider id=946]
Need More?
Get the pro version:
- Search with Ajax 🙂
- Filter by Date, Author & Post Meta / Custom Fields
- Sort results by Post Meta / Custom Fields
- Range Sliders and Range Fields for Meta Data
- Drag and Drop user interface – makes it incredibly easy to build a granular search form
- Works with WooCommerce, Advanced Custom Fields Plugin & more
- Dedicated Support
Links
– Official Documentation
– WordPress.org Plugin
– Github Project
Ritch
Hi, Ross. This is a great plugin – thank you. I have a question related to Cale Lee’s question earlier in the thread. Basically I’m using your plugin to filter ‘Courses’ my clients’ company offers. I’m using a custom post type to enter the courses (as they’re added as posts so I can tag / categorize them). However, the results the filter returns are displaying on the archive template, rather than the custom archive I’ve built. This in itself isn’t such a massive problem, but the archive page excerpts link to the courses within the theme’s generic ‘single’ template, and not the custom single template I’ve built. This is an issue as I have a specific layout for the course pages. So, in a nutshell, is there a way of specifying what template the results are called to? Or am I being a complete dumbass and missing something?
As I said, this is a cracking plugin – you’ve done a great job creating something so effective (that perhaps should really be in the WP core) and I’ll be giving you a high rating regardless of your answer to the above query.
Cheers,
Ritch
Ross Morsali
Hi Ritch, thanks for the message, yeah this is something that I didn’t think there was a huge need for but as its come up a few times I’m going to have to look at this sooner rather than later 🙂 I haven’t started this functionality yet but plan to do so in one of the next releases!
Thanks
Mohammed
That worked like a dream . Thank you so very much Ross. I used a Simple Taxanomy to create seperate taxonomies and then searched them using the plugin. Thank you so very much.
Carlo
Hi,
I use thesis 2.1x framework
when i add this shortcode for example in my home page template it will display nicely (didn’t add styling yet) but it does not provide output
so i can search the hell out of it 🙂 but i get no results… i think it should have to show the “search result” template page won’t it?
(i also tried the advanced wp query search plugin and that automatically does do that… but i’d like to try different plugins before i choose)
Ross Morsali
In its simplest form, this plugin does the same as what the built in WP search functionality does – is there already a search box in your theme? how does this work?
if you type in “www.yoursite.com/?s=test”, in most themes, and the standard way WP works, this URL tells wordpress you are searching for a search term “test”, does a URL like this provide any results? I would likely think that there is an error or conflict somewhere, as this plugin handles basic searches the same way as WP does when it comes to search terms (ignoring taxomonies and filters) – basically, the plugin itself does not do any “searching” but makes a nice URL like above so it can tell WP to perform its search.
Let me know on the above and I’ll try to help you out a bit more.
Ross Morsali
Hey Carlo, this now uses the search template if you use the widget with a search field 🙂
Mohammed
Ross…seems like a fab work ..Iam going to use and rate your plugin at my site where i need to search my listings. Iam creating a real estate site where i want 3 dropdowns(preferably 4) First dropdown with set of categories related to property type, and then another with set of categories related to price and so on. Somewhat similar to that which is on this site http://www.realestateindia.com/ Am I doing somethin wrong in the process. Is it possible to have specific sets of categories listed?
Ross Morsali
Hi Mohammed
This sounds like exactly what the plugin is used for, except the different “categories” you mention are in fact “taxonomies” (which includes categories, tags and custom taxonomies). For pages/posts/custom post types, you can set up all these different variables using a combination of taxonomies to create filters for all kinds of things (price, colour, size etc( – you can do this programatically or you can use a plugin like Ultimate Taxonomy Manger to create them for you.
Once you’ve set all this up and have your taxonomies working for you in the way you want, you can use this plugin to create filters for each taxonomy (checkboxes, radio buttons, dropdowns etc) – just take a look at the docs for usage examples – http://docs.designsandcode.com/search-filter/
Hope that helps
Ole
Thanks a lot for the useful plugin!
What about adding “author” to the taxos?
Greetings, ole
Ross Morsali
Sounds like a good idea, will stick that on the roadmap 🙂
Zygotti
Thank you very much for this plugin. I’m yet another who’s investigated many search plugins without finding one that filters results in the way I wanted – this one does!
I do have one minor quibble though – since it doesn’t filter by post date (are there plans to add this btw?) it’s convenient to have search results ordered by date. Usually this is the case but I’ve noticed that some searches (by category and tag) give results that are not always in complete date order. It’s not my theme and it’s not other plugins – any ideas?
Thanks again.
Ross Morsali
Hi Zygotti I’ve replied over on the WordPress site – http://wordpress.org/support/topic/date-order-of-results
Michiel
Hi Ross!
Thank you for your quick reply!
I succeeded in hiding the submit button, thus assigning a class to the ‘search and filter’ widget.
I tried implementing the few lines of Javascript but I’m probably not doing it the right way because my website’s content & sidebar doesn’t get displayed anymore.
So my S&F widget gets implementend in my ‘sidebar.php’ with the shortcode:
‘echo do_shortcode( ‘[searchandfilter taxonomies=”category,post_tag” type=”checkbox,checkbox” search=”0″ submitlabel=”Submit” class=”sfclass”]’ );’
Where exactly do I put the:
$(‘.sfclass input’).change(function() {
// Something has changed
$(‘.sfclass’).submit()
});
?
Inside the same sidebar.php, or somewhere else? Also, do i need to tell my sidebar.php that there’s going to be some javascript?
Sorry for the, perhaps, simple questions but I’m quite new at this.
Thanks, again, in advance!
Ross Morsali
Hi Michiel
I’m sure your theme uses a javascript file somewhere which handles all of the javascript for that specific theme, you will want to add it in to that.
For example, in the default wordpress 2013 theme there is a file at `js/functions.js`, I would add the code in here after `( function( $ ) {` and somehwere inside this bracket. To be honest what your asking for is a bit out of the scope of support for this plugin.
You really should get familiar with jQuery (and where to place jQuery code) and also how to load javascript in to your wordpress theme (http://codex.wordpress.org/Function_Reference/wp_enqueue_script) although this is all probably a bit confusing… I would just say for now paste the code in to a JS file within your theme, if you want to send me a link I could probably tell you which file?
Thanks
Michiel
Hi!
Excellent plugin.
One question though: would it take much tweaking to loose the ‘submit’ button and auto-submit and refresh at every new checkbox clicked/ticked?
Ross Morsali
This shouldn’t be too difficult in principal just using JS and CSS, first hide the submit button using css, if you look at the documentation in the admin section you can give your Search & Filter widget a class, so if I named the class something like “sfclass” I would use css like:
.sfclass input[type=submit]
{
display:none;
}
Then you want to use some Javascript to detect any change in the form and perform a submit… I guess it depends a little on what you have but using jQuery it would be something like:
$('.sfclass input').change(function() {
// Something has changed
$('.sfclass').submit()
});
This code is untested, but should detect any change in the form and submit the form immediately… if you wanted this to only work on checkboxes and dropdowns you would do something like:
$('.sfclass input[type=checkbox], .sfclass input[type=select]').change(function() {
// Something has changed
$('.sfclass').submit()
});
Let me know if this helps 🙂
Kamil
Hello, I use the plugin wp catalogue and i want to do filtering by brand, but it does not work. I have created my own custom field called product_marka (all brands, brand A, brand B). Wp catalogue does not have a service tag, can I use the plugin wp search and filter for filtering of products in the plugin wp catalogue, by own field?
Ross Morsali
I’m not familiar with WP Catalogue, does it create custom taxonomies? If you go to the plugins admin tab (Search & Filter) you should find a table with all your public taxonomies, is the field you want to filter by listed here? 🙂
arnaudov
Hello Ross,
So far the best search/filter plugin that I could find. I install it but don’t know how to configure it. Is there an option to make limited search through my Public Post Types? For example: I have two CPT and I need to make selection where to search. And the final result in front end should look like:
Search Field
Categories [select]
Page [checkbox]
Post [checkbox]
CPT1 [checkbox]
CPT2 [checkbox]
Search [Button]
Thanks.
Ross Morsali
Hi Arnaudov
I need to update this blog post to the current version and also to link to the new docs, which you can also find in the plugin admin panel – http://docs.designsandcode.com/search-filter/
Hopefully this should help you out…. The shortcode you are looking for would be something like this:
`[searchandfilter taxonomies=”category,page,post_tag,cpt1,cpt2″ type=”select,checkbox,checkbox,checkbox,checkbox” search=”1″ submitlabel=”Search”]`
To control specifically the post types that are searched using the widget you would also need to add `post_types` (currently undocumented):
`[searchandfilter taxonomies=”category,page,post_tag,cpt1,cpt2″ type=”select,checkbox,checkbox,checkbox,checkbox” search=”1″ submitlabel=”Search” post_types=”post,page,customposttype,customposttype2″]`
Let me know if this works?
Thanks
Mounir
Hi Ross,
I think Lee was refering to search templates used by the theme.
In my case for example, when I use one of the built-in taxonomies of the theme in the search, it returns the results in the wanted themes’ template, but when the no value is selected in the dropdown or only values from taxonomies I have added through Ultimate Taxonomy Manager, it return the results as regular posts and not as Listings. The results it show are correct but it doesn’t use the right template to show them.
One solution for my issue would be to be able to specify a default value for one of the taxonomy dorpdowns and even if possible, exclude the “All items” value from that dropdown.
Could you help me on this ?
Ross Morsali
Hi Mounir, thanks for the message, does appending a `?s=` (a blank search) to one of those URLs help to force load a results page rather than just a listing page?
I am testing everything on WP 2013 theme, and these different pages look the same, a blank search term doesn not seem to load a search results page, however the blank search (`?s=`) may force load the results page in your theme?
Let me know 🙂
Cale Lee
Hi again Ross,
is there any way to specify the template used to show the results list?
Thanks!
Ross Morsali
Hi Cale unfortunately not, there should only be a finite number of templates used in the WordPress template hierarchy, which I think in the case of this plugin are limited to: Category, Tag, Taxonomy & Search, so you would likely need to modify these templates pages if you are looking at customising the results pages. There are too many variables between themes and plugins that something like this would likely conflict with so I’m not sure I would include this feature in the future.
Out of curiosity, could you give me a use case for this, so I can get a better understanding of why & how someone (ie you!) would need this?
Cale Lee
Perfect Ross!
Now it works perfectly!
Many thanks for your time.
You have my review on the plugin page.
😉
Ross Morsali
No worries thanks for the feedback 🙂
Cale Lee
Hi Ross,
thanks for your time again!
It doesn’t work… It’s driving me crazy… Your explanation is very clear, and also looking in other forums about restricting search queries, I found the same or similar instructions as yours.
I’m thinking on it, and maybe the wp-types plugin is making some interaction? I don’t know.
I will try it again, when these modifications that you are making to the plugin, have been done.
Many thanks again! I’ll be looking for the update!
Ross Morsali
Hi Cale, the update is now live! Take a look online or via WP, there should be some instructions in WP settings page for the new option, I need to update the online documentation but it looks like what you need to do in your shortcode is:
[searchandfilter taxonomies="custom_taxonomy_one,custom_taxonomy_one" type="select,select" post_types="post,page,custom_post_type"]
.🙂 Let me know how you get on!
Cale Lee
Hi Ross, many thanks for your quick answer.
I try it, but it doesn’t work…
But I make some tests, and I’ve seen that:
– It actually works when activating the search box (it was hidden so it makes no sense in my particular case) and I perform a search writing something.
I’ve used the wp-types plugin to create the CPT, I don’t know if this is relevant.
Also I’ve seen that when doing the multiple search with the 3 dropdwons in “all” mode, the results only show the regular posts, but none the CPT ones.
in effect, selecting only one of the parameters, and leaving the other in “all”, the results are restricted to that particular CPT.
Thanks for you help!
Ross Morsali
Ahh I see what is happening…. basically when the URL has a `?s=` then `$query->is_search` is set to true, so if you removed the `if` statement, your whole site would only return posts of the types you selected below.
We need to make this `if` statement work for all the pages you are seeing your results on, so if you submitted a search without a search term you might land on a page like:
`www.yoursite.com/?customtaxonomy=taxonomy1`
To make the post type filters work on this page also, you might have to do something like:
if (($query->is_search)||(is_tax()) {
$query->set('post_type', array('post', 'custom_post_type')); //here we set the post types that we want WP to search
};
This means the post type filters would work when you have performed a search or on an taxonomy page. Come to think of it, it is entirely possible you might land on a category page, tag page, or a taxonomy page, or a search query… so a more comprehensive example should be:
if (($query->is_search)||(is_category())||(is_tag())||(is_tax())) {
$query->set('post_type', array('post', 'custom_post_type')); //here we set the post types that we want WP to search
};
Remember this is untested 😉 Just to let you know, from your post, I am making modifications right now to the plugin, so you can simply set the post types in the shorcode 😉 Should be live in the next hour or two! 😀
Cale Lee
Many thanks for this great plugin!
It deserves a very good rating in the WP plugins directory!
I have three different dropdowns, each one for a different taxonomy, but all three taxonomies are related to a single custom post type.
The plugin works perfect when selecting a value for each taxonomy, but when in the three dropdowns “all %name-of-the-taxonomy%” is selected, it shows all the posts of my site: the uncategorized ones, and the ones that have taxonomies not related with this custom post type…
I just want to show results for this specific custom post type, in other words, when I select “all…” in the three dropdowns, it should show only the posts with at least one of this taxonomies, but not posts that don’t have any of these taxonomies…
Any ideas?
Many thanks!
Ross Morsali
Hi Cale, the plugin works so that it uses the built in search functions of WP without modifying any queries (just url modifications) in order to display your search results. Modifying the default search behavior is kind of out of the scope of this plugin, I may include such functionality in the future. Hopefully I can help anyway:
If you have 3 dropdowns for custom taxonomies, when searching they will be used, and because they are all for a specific post type, selecting one of them will only ever return results for that custom post type.
However, if you leave them all blank, or set them to “All”, WordPress carries out its search with no constraints – it will return everything. If you do not want your searches to return all posts (or the default post types for search results within your theme/setup) then you need to modify the search query, and add/exclude the post types you want to display when a search has been performed.. This is not tested but is the general idea:
function filter_search($query) {
if ($query->is_search) {
$query->set('post_type', array('post', 'custom_post_type')); //here we set the post types that we want WP to search
};
return $query;
};
add_filter('pre_get_posts', 'filter_search');
You can add this in your themes `functions.php`. This will in effect modify your search query with the post types you want to see, in this example all searches would only display post types of `post` and `custom_post_type`.
Let me know if this works, and if you like please leave feedback over on the plugin page 🙂
Lee
Yeah, I checked that ?s= thing and it returns all posts. I look forward to the update!
Ross Morsali
Hey Lee, this was updated yesterday in v 1.1.1, just check your plugins page within WP admin and upgrade 🙂 If you’re happy with the plugin would really make a difference if you could leave a rating over on the WordPress plugins page 🙂 http://wordpress.org/plugins/search-filter/
Lee
Cheers Ross! That worked a treat! I was using Ultimate taxonomy manager and found the ALL_ITEMS thing there.
There is one other thing. I’m using 2 drop boxes at the moment. If I leave both fields blank then the search doesn’t return any results. How can I either a) get it to show an error message and tell the user to select something or b) just list all posts related to the search.
Thanks again mate!
Ross Morsali
Glad that’s helped you out, going to stick this info in the FAQs 🙂
Re the results page, can you tell me, if you go to your homepage and add “?s=” – without the quotes, to your website address (eg “www.yoursite.com/?s=”), do you see the kind of page you are talking about? Putting this is the URL basically tells wordpress that you have performed a search with no search term which basically should return all your posts…? Let me know would be good to find out.
There is a big update coming today which includes this and a few new things 😉
Lee
Hi, I started using your plugin and I’m making some progress towards my goal. It was working better earlier but I did an update and some progress got undone.
My problem is that I want a label beside the dropdown box to help users select instead of it just saying All Locations, for example. After the update the word Locations has disappeared and just the word All is left which is not informative 🙁 Can you help me fix it?
Ross Morsali
Hi there Lee
Sorry to hear your having a problem. This plugin has never supported having a label next to the dropdowns (it will happen in future) but I think the problem you are describing is due to an update as documented on Github (should also put this on the official plugins page) – in one of the updates, the way the dropdowns are created has changed.
When using a custom taxonomy the plugin used to use the following string:
“All +`taxonomy->name`”
However I realised this was actually incorrect. When registering a custom taxonomy you have the option to fill in a label for “all_items” – this is a label used when referring to all the items of a taxonomy, for example, for tags it is “All Tags” and for post Format it is just “Format” – which the plugin now uses. This is the correct way to use a taxonomy and gives you much more flexibility with the labelling, because sometimes you do not want it to say “All”.
It sounds like you did not fill this in properly. Please see the wordpress codex section on registering taxonomies – and look under “arguments” to see the “all_items” argument I am referring to.
If you have used a plugin to register a custom taxonomy this info can normally be found under advanced settings.
Let me know if this helps? Thanks
James
Hey there,
Just wanted to say great job on the plugin, I had run through the same gauntlet of plugins as yourself and none of them were up to scratch. Your solution is simple and super effective! Thanks a bunch! 😀
Ross Morsali
Thanks glad it’s helped you out 🙂
If you’re registered, please consider leaving some feedback on the wordpress plugins site 😉 http://wordpress.org/plugins/search-filter/