About the only big disappointment with WordPress that I've ever had is that you can't do any kind of advanced searching and none of the available plugins seem to get the job done either.
After I put together my own little hack for searching in multiple categories, I had the idea to make something more advanced that handled tags and terms as well. It was a bit weak, but I learned a lot.
For the last year and longer, I've had requests and suggestions for features such as making it widget compliant and capable of searching custom fields.
I'm happy to announce that after over 100 hours of development, I have finally completed the first ever Jsearch plugin. Each prior version was just a code hack, but this one handles pretty much everything I've ever been asked to include.
Allows your visitors to do advanced query building using a slick and simple interface. For example, they could:
- Search for items in the beach or mountain categories with the resort keyword as long as it didn't contain the complete dump tag.
- Search for any posts, pages, or both that contain the word monster in the title.
- Find anything tagged with Michael Jackson that was also in the Photo Gallery category that did not include the keyword Presley
Clearly, you can get very, very specific about what you're looking for.
Strong Administrative Control
In the Jsearch administration screen, you can set default options for most aspects of the search as well as whether your visitors can change that option or not. Nearly every control can be hidden preventing users from changing your preferred way of searching.
There are 2 default listing styles (Jsearch default and WordPress default) and 3 custom templates that can be configured as needed.
This allows you to style and customize your results just like you would for any WordPress template. You can also have multiple views in the same WordPress installation depending on the need. For example, for normal results on my City of Heroes fan page, I like the results to be the Jsearch Default, but then I used the Custom1 template and customized it to show a thumbnailed list when browsing the image gallery.
Note that the custom template I used to make the thumbnails is included as Custom1 as a sample, but will not work on your page since I use a plugin that you don't have in it. It is only included so you can see how the code can be done (if you want to see it working, go here: Jordan's Town Gallery).
Full URL Customization
Every aspect of the jsearch control (and a few others) can be set via the URL. For example, the thumbnail search I just mentioned is triggered by loading the search page with the following variables in the URL string:
- &cat_all=106 – 106 is the id of the Gallery category. This restricts all results to gallery photos only
- &ppp=24 – Sets the number of posts per page to 24
- &control_vis=min – Minimizes the Jsearch control on first page load (this is a new feature that makes the control stay out of the way until it's needed).
- &results_type=custom1 – Sets the results template to Custom1
- &order=asc – Sets the results to show in ascending date order (WordPress default is descending order). I do this for my gallery so that when you bookmark a page, new additions don't change the photos that are on page 295 for example.
Using this method, I can have the standard defaults as set in my administration panel, but create tailored views on the fly using nothing more than a link with some variables.
If you want to see how it works first, just try it out. Otherwise, download it and try it here.
Once downloaded, follow these instructions:
- Unzip the plugin to your plugins/jsearch folder like this:
- Copy the jsearch_template.php file to your current theme's directory so it's available to your theme to be selected as a page template.
- Create a new page using the Jsearch template.
- Click on the "Jsearch Config" link in the plugins area on the left menu in the WordPress dashboard. On that page, select the page you just created in the drop-down list (so the plugin knows which page is using the template) and click "SAVE" at the bottom of the settings page.
- Mess with the other settings if you wish, but you're basically done (if you do change something, remember to click "SAVE" at the bottom to save the changes).
- (Optional but recommended) Replace the normal search widget in your sidebar with the Jsearch equivalent. This customized search box will feed directly to the Jsearch page and contains an "Advanced Search" link that will go directly to the search page without having to enter any terms first.
NOTE! I know there's an error where even after setting and saving the Jsearch target page, you'll still see a notice saying you haven't, but that will go away on it's own. I don't know what causes it but when I do, I'll put a fix in for it.
The Newest Version
|About Jsearch Version 2 - Leaner interface, custom-built query that handles all the hard searches that WP doesn't.|
|Jsearch Tutorial - For site visitors and users of Jsearch to learn (very quickly) how to USE the Jsearch interface.|
|Jsearch Setup - Download and learn how to install and customize Jsearch here. For site administrators who want to use Jsearch on their site.|
Older Versions (for historical purposes)
|Version 1 - Jquery enabled and functional, but awkward to use in some ways.|