Raw Code Meta Box

//functions.php

function favourite_food(){
add_meta_box(
'fav_food_meta',
'What is your Favourite Food ???',
'meta_box_op',
'page',
'normal'
);
}
add_action('add_meta_boxes','favourite_food');

function meta_box_op($post){
?>
<label for="food">Type your favourite food</label>
<p><input type="text" id="food" name="zboom_food" class="widefat" value="<?php echo get_post_meta($post->ID,'zboom_food',true); ?>" /></p>

<?php
}

function food_send_to_database($post_id){
update_post_meta($post_id,'zboom_food',$_POST['zboom_food']);
}
add_action('save_post','food_send_to_database');


//page.php

<?php echo get_post_meta($post->ID,'zboom_food',true); ?>


Comments

Popular posts from this blog

WP register_post_type() with custom CMB2 meta box

Git post receive setup at server for git push to the production from local machine