• Resolved rmlumley

    (@rmlumley)


    I’ve created some custom meta_box text fields that work fine. They display and save. I’m trying to create one check box meta_box that isn’t working for me.

    <?php
    function admin_init() {
       add_meta_box("event_novel", "Novel Type", "novel", "events", "normal", "high");
    }
    function novel(){
      global $post;
      $custom = get_post_custom($post->ID);
      $novel = $custom["novel"][0];
      ?>
      <input type="checkbox" name="novel" value="<?php echo $novel; ?>" />  This is a novel.
    <?php } ?>
    
    <?php
    function save_details(){
       if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
       return $post_id;
       global $post;
       update_post_meta($post->ID, "novel", $_POST["novel"]);
    } ?>

    This displays the checkbox, but it doesn’t save. What do I need to do to check if that checkbox is saved and then display it checked (if it’s saved)? Furthermore, how do I later call to that value (if it’s checked) in the loop later on.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Saving meta_box checkbox’ is closed to new replies.