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 am using tagit Tagit for my wordpress site for adding tags through front-end. So far the taglist is displaying fine through json (for json I use the json api

However, I can not get the autocomplete to work. If a user starts typing on the input field it displays all the tags. But I want to filter the taglist as soon as the user starts typing (if a user types 'mijn' the results should be 'termijn' but also 'mijnserver'.)

This far I have to following in my function:

    $value = '';

if ( $post_id ) {
    $post_tags = wp_get_post_terms( $post_id, 'post_tag' );
    $tagsarray = array();
    foreach ($post_tags as $tag) {
        $tagsarray[] = $tag->name;

    $value = implode( ', ', $tagsarray );

<div class="wpuf-label">Business Tags</div>
<div class="wpuf-fields">
    <input type="text" id="test" name="tags" value="<?php echo esc_attr( $value ); ?>" size="40">

The javascript:

    fieldName: "tags[]",
   singleField: true,
    allowSpaces: true,
    minLength: 2,
    removeConfirmation: true,
    placeholderText: 'Kernwoord',

    tagSource: function( request, response ) {
            url: "http://localhost/sbnl/api/get_tag_index/?dev=1", 
           data: {term:request.term},
            dataType: "json",
            success: function(data) {

                response($.map(data.tags, function(item) {
                    return {
                        label: item.title,
                        id: item.id



last bit of the code:


If someone could please help me out

share|improve this question
Is that stray comma after the tagSource function intentional? Does your object include more functions and/or properties not shown above? – t31os Feb 3 '14 at 16:48
You seem to be making ajax request to something that doesn't look like WP endpoint, what is it? – Rarst Feb 3 '14 at 18:06
Well, I found the javascript code on the internet and used it, but if I read your comments this is not going the work...I am new in learning php and javascript :-) – Monique Feb 3 '14 at 18:28

Your Answer


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

Browse other questions tagged or ask your own question.