Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

Figured it out:

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

Easy

share|improve this answer
add comment

Your Answer

 
discard

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.