This is the simple meta-box code
/* simple meta box */
/* creating field */
add_action('admin_menu', 'my_post_options_box');
function my_post_options_box() {
    if ( function_exists('add_meta_box') ) { 
        add_meta_box('post_header', 'Asif, save me!', 'testfield', 'post', 'normal', 'low');
    }
}
function testfield(){
global $post;
?>
<input type="text" name="Asif" id="Asif" value="<?php echo get_post_meta($post->ID, 'Sumon', true); ?>">
<?php
}
/* end of creating field */
/* storing  field after pressing save button */
add_action('save_post', 'save');
function save($postID){
    if (!defined('DOING_AUTOSAVE') && !DOING_AUTOSAVE) {
        return $postID;
    }
    else
    {       
        if($parent_id = wp_is_post_revision($postID))
        {
        $postID = $parent_id;
        }
        if ($_POST['Asif']) 
        {
            update_custom_meta($postID, $_POST['Asif'], 'Sumon');
        }
    }
  }
 // saving in postmeta table
  function update_custom_meta($postID, $newvalue, $field_name){
    if(!get_post_meta($postID, $field_name)){
 // create field
    add_post_meta($postID, $field_name, $newvalue);
     }
   else{
//update field
     update_post_meta($postID, $field_name, $newvalue);
    }
}

My question is on save($postID) function. Here there is a parameter $postID which is using in the function for saving as id. I see that this $postID has a null value. How actual post id works for this variable?

Read more here: wordpress meta-box confusion


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, ,

Wordpress related questions and answers: