This will create a metabox for you to enter a video code.
//Creating a MetaBox for Posts to enter Video Code.
add_action('add_meta_boxes','video_meta_box');
function video_meta_box(){
add_meta_box('video_box_id', 'Enter Video ' , 'video_box_cb','post','normal','default');
}
function video_box_cb($post){
$value = get_post_meta($post->ID,'video_box',true);
echo '<textarea rows="4" cols="50" id="video_box", name="video_box">';
echo $value;
echo '</textarea>';
}
add_action('save_post','save_video_box');
function save_video_box($post_id){
$box_data = $_POST['video_box'];
update_post_meta($post_id,'video_box',$box_data);
}
Use this code to render this code within your theme.
<?php
$custom_values = get_post_custom($post->ID);
echo '<p> Video CODE: '.$custom_values['video_box'][0].'</p>';
?>
5
solved Create A Metabox For A Custom Field