I have a custom post type and I created it using the following code.
/* DRAMAS */
register_post_type('dramas', array(
'label' => 'Dramas',
'show_ui' => true,
'supports' => array('title', 'thumbnail', 'custom-fields', 'description'),
'labels' => array (
'name' => 'Dramas',
'singular_name' => 'Drama',
'menu_name' => 'Dramas'
),
) );
Following code for the meta box mark up
<?php
function custom_meta_box_markup() {
$meta_box_text = get_post_meta( $post->ID, 'meta-box-text' );
?>
<div>
<label for="meta-box-text">Day</label>
<input name="meta-box-text" type="text" value="<?php if ($meta_box_text) { echo $meta_box_text; }?>">
</div>
<?php } ?>
And my meta box code is:
function add_custom_meta_box()
{
$id = 'demo-meta-box';
$title = 'Schedule';
$callback = 'custom_meta_box_markup';
$screen = 'dramas';
$context = 'side';
$priority = 'high';
$callback_args = 'null';
add_meta_box($id, $title, $callback, $screen, $context, $priority, $callback_args);
}
add_action("add_meta_boxes", "add_custom_meta_box");
Now I see the meta box like this:
I am able update the values and publish the post now. But when I add a some thing in the above metabox and publish it, it is displayed on the custom field right after my editor. NOT displayed on the (schedule) meta box (day) field.
Why is this? how can I solve this?
$meta_box_text = get_post_meta( $post->ID, 'meta-box-text', true );