Is it possible to bring intellisense (autocomplete) in the search box of the website????
Leave a Reply
You must be logged in to post a comment.
Is it possible to bring intellisense (autocomplete) in the search box of the website????
You must be logged in to post a comment.
So you want more general autocomplete, rather than something specific (like blog tags for example)?
If you use (or will consider using) Google Custom Search (which is very popular option to replace native WP search), they made it quite easy to enable native autocomplete with it.
See:
So basically you want Google Instant on your website? That’s not “Intellisense,” but the functionality of the two are very similar.
The short answer to your question is: yes. But the somewhat less helpful question is: it’s not easy.
Decide what you want to search
You can search anything on your site from the search box: tags, categories, custom taxonomies, page titles, post title, page content, post content, etc, etc. So if you just want people searching through the titles of your posts, just have them search through the titles.
Set up an AJAX callback
Google Instant (and similar tools) use AJAX (asynchronous JavaScript and XML) to request data from the server without reloading the page. When you’re typing in the search box, Google sends the text you’ve entered to the server and received a list of results – these are displayed in the Google Instant results below the search bar.
You’ll need to do something similar. As a visitor is typing, you’ll need to dynamically send their input to a PHP function on the server and have it query the database and return a list of matches. If you’re searching page titles, the function will match against page titles and return a list. You can display this in a dropdown box below the search bar.
How to actually do this
You’ve got three options here:
1. Wait for the exact plug-in to be built
I have yet to find a plug-in that does exactly what you’re looking for. So if you’re dead set on just dropping a feature into your site you’ll either need to wait for someone else to do it, or hire someone to write it for you.
2. Modify an existing plugin to do what you need
I’ve managed to find one promising plug-in that claims this kind of functionality: WP Instant Search.
Unfortunately, WP Instant Search is designed to search against post tags and categories, not against post content or titles. To extend the functionality for your purposes, you’d need to modify the plug-in a bit.
3. Develop the feature yourself
Building your own Google Instant-like feature wouldn’t be much more difficult. The basic system is already there: WordPress allows for database searches, has a jQuery backbone built in to the UI for AJAX support, and is infinitely pluggable.
I even found a very complete tutorial explaining how to build a Google Instant-like system into any PHP-powered website using jQuery: How-To Create Your Own Instant Search.