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?


Figured it out:

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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