i was following atutorial on how to make a custom metabox to wordpress post but its giving errors
here is my full code
//Add Metabox
function diwp_custom_metabox(){
//add_meta_box(metabox_id,metabox name,callback function,metabox location(page,post,custom post etc),context-(normal,side,advanced),piority())
add_meta_box('diwp-metabox','My Custom Metabox','diwp_post_metabox_callback','post','normal');
}
//add action
add_action('add_meta_boxes','diwp_custom_metabox');
//metabox callback function
function diwp_post_metabox_callback(){
// echo 'hi i am diwp metabox';
?>
<div class="row">
<div class="label">Post Reading Time</div>
<div class="fields">
<input type="text" name="_diwp_reading_time" value="<?php get_post_meta($post->ID,'post_reading_time',true); ?>">
</div>
</div>
<?php
}
function diwp_save_custom_metabox(){
// update_post_meta($post_id,$meta_key,$meta_value,$prev_value);
global $post;
if(isset($_POST['_diwp_reading_time'])){
update_post_meta($post->ID,'post_reading_time',$_POST['_diwp_reading_time']);
}
}
add_action('save_post','diwp_save_custom_metabox');
any help will be appreciated ,thanks