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

141 thoughts on “Autocompleter

  1. GJtje

    Too bad this handy plugin busts my preview feature on comments (while using Sexy Comments as plugin for that). So I deactivated this plugin.

    Running WP 2.7 beta 3 btw… πŸ™‚

  2. Pingback: New WordPress plugins - 30.11.2008 | - WordPress themes, plugins and news

  3. Pingback: Top Wordpress plugins « Bloc d’en RainCT

  4. Pingback: Siegfried Gevatter: Top Wordpress plugins | Christian eBuddy Blog

  5. snetErz

    For anyone that wants to autocomplete post titles instead of tags, I rewrote the sql query to compensate.

    Under values.php:

    Replace the select query with:
    “SELECT post_title FROM wp_posts WHERE post_title LIKE ‘$search%’ AND post_status LIKE ‘%publish%'”

    Replace: echo $word->name.”\n”;
    echo $word->post_title. “\n”;

    Thanks for a great plugin. =) Happy searching!

    This pretty much just asks for post_title’s that are published so as not to spam the list with the revisions. After all we only need the title. This also removes the media files from the search box as well, because they are posted as inherit.

  6. Nik Chankov Post author

    Thanks for the update snetErz. Although I don’t think that the idea of search is to make autocomplete of the posts.

    The reason why I think this way is simple – autocompleter is just a guide (helper) which will help users to find relevant information. Tags and categories are exactly this.

    Anyway, your comment will be here, so anyone who want to use it with your approach is more welcome πŸ™‚


  7. Cufflinks

    A friend of mine had visited your page few days back and gave me this plug-in for my use. I have to hand it to you it worked just perfect. Just dropped by to thank you for the awesome plug-in.

  8. Lee

    I really like the sound of zero configuration, I have not been happy with the standard wordpress search interface and have been looking for a improvement. Most novices who wish to learn will really benefit from the extra prompting when searching for their requirements. Going to install it now!

  9. Nik Chankov Post author

    Dave, great hint! I will add definitely in the plug-in. I’ve always rely on id’s but never on name attribute, but you are completely right!

    Thank again

  10. Married Chatrooms

    Great work Nik. The plug-in is a really good idea. Never came across anything like it. and it is really useful. Nice tip Dave, I went through the code but i didn’t notice it until I saw your comment. Great job Nik and Dave. Appreciate the efforts. Cheers

  11. Mehmet Karaca

    Referencing the search box using jQuery(”input[name=’s’]β€œ) may be fine for a lot of people, however I liked the old way of using id=”s” better and here is why.

    I have a big old search box in my template in the header section (see

    I modified the plugin css to make the drop down search results box look best (width-wise) with that main search box. The modification involved several tweaks one of which was to give the drop-down a 43 pixel pad on the right side.

    When my visitors reach a 404 page, which includes the theme search form my site displays two search boxes, one in the header and one in the page body — as in

    Because of the 43 pixel right pad, the width of the drop down for the search box in the page body is too wide…

    By not using the id=”s” I was able to exclude the search box in the page body but now I can’t.

    Is there a way to exclude a search field from using the autocompleter?

  12. Nik Chankov Post author

    @Mehmet why dont you remove the second search form? πŸ™‚ easy as that.

    Another option which is coming to my mind is:
    1. rename the search field for example “s1” or “search”
    2. put a hidden field named “s” and on submit make

    $('#s').attr('value', $('#s1').attr('value'));

    third option is to modify the plugin it is one file πŸ™‚ just change it and forget it πŸ™‚

    Hope this will help

  13. Nathan

    A great plugin! But for some reason it doesn’t line up under the search box and sits vertically halfway across the input box. The padding in the css seems to only move the results over, not the box. Anyway I can fix this?

  14. Pingback: Website Update |

  15. Travis

    You’ve done an incredible job with this plugin, Nik.

    One thing I was wondering, if you’ve considered enabling it to suggest terms for multiple words? Works like a charm for the first couple characters you type, but if you add a space and another word, it doesn’t suggest anything else.

    Would you consider such a feature?

  16. Nik Chankov Post author

    Travis, basically you suggesting an Facebook style autosuggest and add, right? If so, it’s not a bad idea… probably I will realize it in the future

  17. Nik Chankov Post author

    Steven, the demo is in the top-right corner of this blog – where the search field of this blog is located πŸ™‚ Try to search for “WordPress” and you will see the demo. πŸ™‚

  18. Pingback: Weitere Wordpress-Plugins gefunden | Von Und Zu

  19. Pingback: Eklenti.Net > Wordpress Eklentileri » Autocompleter

  20. Øyvind Svedman

    Hey, great plugin!

    However, it breaks XHTML 1.0 Strict validation because you didn’t comment out the JavaScript code inside the SCRIPT tag in autocompleter.php lines 55-80. I have added this to my local copy and it now validates. πŸ™‚

    BTW, how can I make the autocompletion drop-down open upwards instead of downwards?

  21. Pingback: » Erneute Umstellung auf

  22. Pingback: » Bessere Suche fΓΌr Wordpress

  23. Levani

    I made a test on this website and noticed that the number of matches is always less than the real number of posts after submitting the search. Should it be?

  24. Travis

    Hey Nik,
    Quick question for you…how would you go about connecting to another WP database?

    As an example, I have one main site, and several sub-domains, each with their own WP install. I’d love to tap the search autocompleter on the main site, into one of the sub-domain’s databases.

    Is there an easy way to add the db path and login info to your plugin, or use the wp-config.php of the sub-domain’s install?

  25. Nik Chankov Post author


    autocompleter is working as wp blog – so only one database. If you want to attach other databases, the easiest way is to edit the values.php and to create extended sql which will collect all tags from all databases.

  26. Chris

    Hey Nik,

    I like this plugin. It works great. I love the zero config aspect of it. I installed it a couple days ago and I am loving it. I also appreciate the help towards getting it figured out.

    Thanks again

  27. Pingback: makomi » Blog | Wordpress-Plugins «

  28. Lisa



    I use wordpress as a CMS and this is exactly what I was looking for. But it seems that it is not working:

    function autocompleter()
        $wpdb =& $GLOBALS['wpdb'];
        $search = $wpdb->escape($_GET['q']);
            $words = $wpdb->get_results("SELECT post_title FROM wp_posts WHERE post_title LIKE β€˜$search%’ AND post_status LIKE β€˜%publish%’ 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");
            foreach ($words as $word){
                echo $word->post_title."\n";
  29. ks

    @ Lisa

    I tried that code and it didn’t seem to work for me either. I don’t know why. I hope he posts…

Leave a Reply

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