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

Right now I'm reading tags from the tag box, and putting them in a form with radio buttons so the user can choose a "main tag" from the tags they just typed in:

function write_tags(){
    var rawtags = $j(".tagchecklist").find("span").text(); 
    var stags = rawtags.split("X");
    var ftags = stags.slice(1);

    document.getElementById('tag_options').innerHTML = '';

    $j.each( ftags, function(i, l){
        $j("#tag_options").append('<input type="radio" name="mainTagButtons" value="' + i + '" /> '+ l +'<br />');


Now that I have these displayed and selectable, I have no idea how to save the selection to post meta, or how to check the value there to see if it's saved. First I tried this:

if (!empty($_POST['mainTagButtons'])) {
  $this->data['mainTag'] = $_POST['mainTagButtons']; }

if ( isset($this->data) && $this->data != '' )
    update_post_meta($id, 'mainTag', $this->data);

But I'm not sure how to test to see if it worked. Any ideas?

share|improve this question

Figured it out:

update_post_meta($id, 'main_tag', $_POST['mainTagButtons'])


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.