A WordPress plugin for adding Autocomplete functionality to your blog search

Plugin download

Brief information
Adding autocomplete functionality to the blog search input field. The values provided are the tags and categories used in the blog.

If you find this plugin useful why don’t you buy me a beer?

Long description
This plugin adding autocomplete functionality to search input field. It is using core jQuery library as well as autocomplete jquery plugin from

This plugin requires zero configuration, but since version 1.2.0 there is admin screen where you can enable the extra ‘number of matches’ next to each option. You just need to activate and it’s ready to be used in the blog. The plugin is tested with WordPress 2.6.5, but until there aren’t big core changes, it sould work for all future releases. I don’t have information if this plugin will work with older versions of WordPress, but for sure it is working with 2.6.x. The last version 1.2.0 is tested on WP 2.7.1.

New in 1.2: This version could display number of matches found in the blog.
New in 1.2.1: Small fix for table prefixes and adding autosubmit once the item from the list is selected.
New in 1.3.0: Added result type option in admin. From now on you can choose which type of results will be displayed.

I would appreciate if you write an review/post in your blog with a link to my page:

Thanks to

This section describes how to install the plugin and get it working.

  1. Download the plugin from WordPress repository
  2. Upload `autocompleter` to the `/wp-content/plugins/` directory
  3. Activate the plugin through the ‘Plugins’ menu in WordPress
  4. {Optional} If you want to change the apperience of the dropdown, just play with autocompleter.css in the plugin folder.
  5. {Optional for 1.2.0} Go to Admin area under the Settings section. There is Autocompleter menu from which you can extend the plugin with ‘matched items’ option.

Frequently Asked Questions
Why this plugin is useful for users of your blog?
It’s useful because they can easily check what themes you writing for, and this way they could find the desired article more easily.

Is it possible to use it with non standard search like Google Custom Search Engine or similar?
Well, depends. Current version (1.1.2) reqires the name of the input field to be “s”, so if your search field has such name, there is no problem at all.

Is it heavy for my blog?
No, it selecting results from two joined tables, and it is not heavy at all.

Is it secure?
Actually it’s escaping the search string with functions provided from WordPress, so it is secure as WordPress.

Use contact page for support and other questions. Thanks!

Autocompleter.1.2 Autocompleter.1.1.2

142 thoughts on “Autocompleter

  1. Pingback: Autocompleter | Blog for web development

  2. obseque

    thank’s for your great work… i would make a search form with autocompletion for only one kind sort of post. Is there anyway to select only the post from one single category ?

    thank’s a lot

  3. Nik Chankov Post author

    It’s cannot be done directly, but you can modify the file which looking up in the tables. Go to /your_server/wp-content/plugins/autocompleter/ and check the values.php

    Basically if you change the SQL it should work

  4. Nik Chankov Post author

    It’s just you Roger, as you can see it’s working on this blog which is updated to last version of WP 🙂

    Tell me how can I help with your case?

  5. Josh

    I think there’s an issue when a search is performed and no results are found.

    For example, I type something in that I know does not exist on my site. It returns with my message that nothing was found.

    I then start typing something I know exists and the autocompleter begins to drop down. I click on something from the list. It does not successfully load that option after clicking. It’s like it didn’t refresh itself, it still thinks I’m searching for my previous entry.

    I have the “Autosubmit the form on select an option” selected.

  6. Pingback: Autocompleter | Blue Orbs

  7. Nik Chankov Post author

    Hi Carl,

    What I can see in your blog is that you have another inclusion of jQuery after the autocompleter one.

    This way jQuery cannot see the autocompleter plugin and the functionality cannot work properly.

    For me the problematic is jCarousel or superfish, but I cannot tell much.

    Try to disable and enable the plugins and you will see it.

  8. jaffamonkey

    Hi! Very nice fast plugin – but ti has some quirky behaviour on mu. When I type in London for example, and select suggestion the resulting search string is /?s=%EF%BB%BFLondon instead of /?s=London. Is this MU related and has anyone esle experienced this?

  9. Pingback: Intégrer des suggestions à votre moteur de recherche de blog

  10. Pingback: Mes favoris du 1-03-10 au 3-03-10 » Gilles Toubiana

  11. John

    Please help me i need my search result shows post title instead of tag please show me tutorial how to do it

    Thanks In advance

  12. Nik Chankov Post author

    Hi John,

    showing the post titles in the autocompleter is like to duplicate the search functionality here. If you want to accomplish this task, you should edit values.php file

    replace this row:
    $words = $wpdb->get_results(“SELECT concat( name, ‘|’, sum( count ) ) name, sum( count ) cnt FROM “.$wpdb->prefix.”terms t, “.$wpdb->prefix.”term_taxonomy tt WHERE t.term_id = tt.term_id AND name LIKE ‘$search%’ GROUP BY t.term_id ORDER BY cnt DESC”);
    $words = $wpdb->get_results(“SELECT concat( post_title, ‘|’, 1 ) name, 1 cnt FROM “.$wpdb->prefix.”posts t WHERE post_status=’publish’ and post_date < NOW() and post_title LIKE '$search%' ORDER BY post_title");

  13. Nik Chankov Post author

    Try to use this instead of the previous:
    $words = $wpdb->get_results(“SELECT concat( post_title, ‘|’, 1 ) name, 1 cnt FROM “.$wpdb->prefix.”posts t WHERE post_status=’publish’ and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title"); The change look into any word in the page title instead of the beginning only.

  14. Nik Chankov Post author

    ok, sorry, I didn’t understood you correctly from the beginning.

    The correct code should be:

    $words = $wpdb->get_results(“SELECT concat( post_title, ‘|’, 1 ) name, 1 cnt FROM “.$wpdb->prefix.”posts t WHERE post_status=’publish’ and post_type=’post’ and post_date < NOW() and post_title LIKE ‘%$search%’ ORDER BY post_title”);

  15. chris

    just a fyi, this plugin does not work with newest version of wordpress, it spits out errors regarding depreaciated functions, etc.

  16. Nik Chankov Post author

    I am with the final stable version of WP and there are no problems so far. When the new version arrive I will update the plug-in accordingly.

    But anyway. thanks for the hint.

  17. seezer

    I’ve got a little problem with this plugin: when I try to enter some non-existent query in search field (i.e. I begin to type “qwer” – and sure, there is no such tag), I get error message in search field: WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed!

    I don’t get it anywhere else, so I’m sure there’s no problem with WP Super Cache plugin.
    If I enter exisiting tags, everything’s OK.

  18. Nik Chankov Post author

    Yep, it works. I’ve tested with the nightly build of the WP before the official release, as well as now this blog is upgraded to 3.0 and the plugin still works (see search form).

  19. nomi

    Hey nik, Thanks for the amazing plugin , kindly tell me how can i choose only tag to find for search box ?? in which file i can define that which type it should find ,like tag or category , actually i just want to allow it to find tag not categories,
    With Thanks ,

  20. Nik Chankov Post author

    The plugin has new version – 1.3.0

    Now you can choose what king of results will be displayed. Check the admin panel to see all available options.

  21. nomi

    Thanks A looot niick , Love your Plugin , i really can’t thanks in words my friend, wish you Joy and Happiness,

    Pray for you,
    Take care ,

  22. Nik Chankov Post author

    @nomi, without testing I think it should work.

    If it doesn’t I will help you you can always uninstall and get an older version. But I am 99% sure that it will work.

  23. Hugh

    Wow, what an amazing plugin! Thanks so much for it 😉

    Quick question, I have the plugin installed (it was super easy) and I selected ‘Only Categories’ and ‘Autosubmit the form on select an option’. How can I have it so that when a user selects an option, they’re just redirected to the category page itself?

    Thanks again for a great plugin 😉

  24. Pingback: Wie kann ich “Autocomplete” bei der Wordpress-Suche hinzufügen? - [beantwortet] -

  25. Peter

    Awesome plugin. Would be good to have this as a widget so that an “ordinary” search box could be used independently … this would help where tag lists are long (eg: list of cities) and may confuse a user trying to search on other types of keywords.

  26. Jonathan Dingman

    I tried to get this working, but it’s a no go.

    Is there something I’m missing for my search form?

    Please check my page if you can.

    I refreshed the cache for my site already, I have the plugin enabled, but it’s not working.

    The autocompleter files don’t show up in the HTML either, not sure why.


  27. Nik Chankov Post author

    Hi Jonathan,

    your problem is because you include jQuery 2 times in your page. Autocompleter includes the standard jQuery library from the WordPress, while you are using another plugin which includes jQuery separately and because it’s re-included Autocompleter’s methods are overwritten.

    What you can do is to deactivate your other plugins one by one to see which cause this problem, and then to remove the jQuery inclusion from it.

  28. Jonathan Dingman

    Hi Nik,

    Thanks for the suggestion.

    I’m purposely including jquery already as I need it for my theme.

    It’s definitely possible to make autocompleter smart enough to detect if it’s already been loaded using the script loader API. Why not adjust the code to do that? That way it won’t be loading it twice.

    Thanks Nik

  29. Nik Chankov Post author

    The plugin code uses wp_enqueue_script() function which actually check if other plugin call that script. But I cannot check if someone manually add jquery lib in the theme. 🙂 Anyway, I believe that the problem is not of double inclusion, but because the stream is following:
    jQuery.js (my call)
    autocomplete.functions.js (autocomplete specific functions)
    jquery.theme.js (your jquery inclusion)

    If you move the code just below your tag it wont be a problem. So the code would be:
    jquery.theme.js (your jquery inclusion)
    jQuery.js (my call)
    autocomplete.functions.js (autocomplete specific functions)

    and it would be fine.

  30. Jonathan Dingman

    Ah great, sorry my bad on that.

    I deregistered both jquery and SWFObject (even though I know only the jQuery call was required) and used the register_script method and it worked like a charm.


    great plugin, keep up the good work.

  31. Jonathan Dingman

    One other thing.

    Wouldn’t it make more sense after showing the instant results, that when the user clicks on the result, it sends them directly to the post/page/tag, rather than the search result?

  32. Nik Chankov Post author

    Basically the idea of Autocompleter was to be a helper to the user while he search to give hints what is available on the blog, it’s never wanted to be a fully replacer of search functionality. If you want to access tags or categories, create a tag cloud or category structure. 🙂

    At least that’s my understanding. That’s why I am not implementing such functionality 🙂

  33. Caner

    Hi, i’m using this plugin in my site ( and i want to some changes.

    For example:

    search query | category | x matches

    is this possible?

  34. Nik Chankov Post author

    About the previous comment – yes it’s possible. the plugin is not so complex, but this is not the main purpose of the plugin. The plugin is for “search helper” rather to be a replacer of it. 🙂

    About the second question – it’s very easy, you need to modify your css of the template, or you can change the plugin’s css file. Check your plugin’s directory.

  35. Dan

    Hey Nik,

    Any thoughts why this doesn’t work if it’s used on a subdomain ?

    It works perfectly while used on the main blog but if I intend to search on a subdomain of that blog it doesn’t work.

    I checked and it seems like the GET method of the JS is not working. That’s as far as I managed to get with my debugging.

    Any help would be much appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *