/*-------------- Called Post Meta -----------------*/
function meta_box_part()
{
add_meta_box("meta-box-section", "Section List", "custom_meta_box_markup_section", "your-post-type", "side", "high", null);
}
add_action("add_meta_boxes", "meta_box_part");
/*-------------- Add Post Meta -----------------*/
function custom_meta_box_markup_section($object)
{
// code goes here...
}
/*-------------- Save Post Meta -----------------*/
function save_custom_meta_box($post_id, $post, $update){
if (!isset($_POST["meta-box-nonce"]) || !wp_verify_nonce($_POST["meta-box-nonce"], basename(__FILE__)))
return $post_id;
if(!current_user_can("edit_post", $post_id))
return $post_id;
if(defined("DOING_AUTOSAVE") && DOING_AUTOSAVE)
return $post_id;
$meta_box_value = "";
if(isset($_POST["custom_input"])){
$meta_box_value = $_POST["custom_input"];
} else{
$meta_box_value = '';
}
update_post_meta($post_id, "custom_meta_name", $meta_box_value);
}
add_action("save_post", "save_custom_meta_box", 10, 3);
Like this:
Like Loading...