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

Tag-it is a jquery UI plugin that allows assigning tags, exactly like tags system in stackoverflow. https://github.com/aehlke/tag-it/blob/master/README.markdown

My goal is to allow members of my wordpress site to post from front end. To do so, I have created a form with input fields. I get the input content using $_POST['something'].To insert the post data (title, content, custom fields values), I use wp_insert_post function, and it is working well.

And to insert tags for the specific post I use wp_set_object_terms function (since I am using custom post type and a taxonomy for tags). This last function is working well if I assign some sample values to it but I cant get the input values of the tags input created by tag-it. I tried my best to link between the plugin and the PHP code responsible of assigning tags to my post in WP DB.

In fact, in my code source I put:

<ul id="myTags">

And this code is transformed by the plugin (after execution) to :

<ul id="myTags" class="tagit ui-widget ui-widget-content ui-corner-all">
<li class="tagit-new">
<input type="text" class="ui-widget-content ui-autocomplete-input" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">

How can I retrieve the POST variable from this input field as an array, so that I can put it in the parameters of wp_set_object_terms ?

Your usual help is always appreciated.\

share|improve this question
up vote 1 down vote accepted

I added the fieldName parameter to tagit function like this:

<script type="text/javascript">
    $(document).ready(function() {
        fieldName: "tages[]"

Now I can echo $_POST['tages']; since the HTML after execution became:

<input type="hidden" style="display:none;" value="d" name="tages">

In addition, $_POST['tages']; is a PHP array which I can directly put in second parameter of wp_set_object_terms.

Thank you very much, some problems take a lot of time to resolve, but only before posting them on SE.

share|improve this answer

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.