WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating my own form based on this and I'd like to have a tag selector which is similar to the one on StackExchange. I can roll my own but I was wondering if something similar already exists.


share|improve this question
up vote 3 down vote accepted

you can do that using JQuery autocomplete plugin

and once you have included all of the needed JS files just add this code after your new post form

$terms = get_terms("post_tag");
$tags = '';
$count = count($terms);
 if ( $count > 0 ){ 
     foreach ( $terms as $term ) {
       $tags .=  '"'.$term->name.'", '; 
    $tags = substr($tags,0,-2);

echo ' <script>
JQuery("#post_tags").autocomplete(['.$tags.'], {
        width: 320,
        max: 4,
        highlight: true,
        multiple: true,
        multipleSeparator: ", ",
        scroll: true,
        scrollHeight: 300

note: Now this is good if you only have a small number of tags, but if you have hundreds or thousands of tags then using an ajax solution is a must.

share|improve this answer
Could you expand on "once you've included all the JS libraries" a bit more please? I'm actually trying to create my first plugin that is a tag search form, and it should function exactly like the jquery autocomplete demo (jqueryui.com/autocomplete/#multiple) with multipe comma delimited values. Although I can get this to work fine in a standalone application, it doesn't work in a plugin. I'm not sure what library files or how they should be included in the plugin. Using WP 3.9 – user658182 Apr 18 '14 at 3:06

Look at the code for the tag box in wp-admin/includes/meta-boxes.php and the function tagBox in wp-admin/js/post.js. You may adapt or reuse these functions.

share|improve this answer
Dear toscho, what is the actual equivalent of 'post.dev.js' in 'wp-admin/js/'? I dont find this file in WP 3.5+. Thanks – whiteletters in blankpapers May 24 '13 at 15:05
@whitelettersandblankspaces It is just post.js now. – toscho May 24 '13 at 15:07
Thank you very much. Have a nice day. :-) – whiteletters in blankpapers May 24 '13 at 15:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.