// Add the Meta Box function add_custom_meta_box() { add_meta_box( 'custom_meta_box', // $id 'Slide details', // $title 'show_custom_meta_box', // $callback 'slides', // $page 'normal', // $context 'high'); // $priority } add_action('add_meta_boxes', 'add_custom_meta_box'); // Field Array $prefix = 'wtf_'; $custom_meta_fields = array( array( 'label' => 'Slide Image', 'desc' => 'Copy paste the uploaded image url here.', 'id' => $prefix.'slide', 'type' => 'text' ), ); // enqueue scripts and styles, but only if is_admin if(is_admin()) { wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_script('jquery-ui-slider'); wp_enqueue_script('custom-js', get_template_directory_uri().'/js/custom-js.js'); wp_enqueue_style('jquery-ui-custom', get_template_directory_uri().'/css/jquery-ui-custom.css'); } // add some custom js to the head of the page add_action('admin_head','add_custom_scripts'); function add_custom_scripts() { global $custom_meta_fields, $post; $output = ''; echo $output; } // The Callback function show_custom_meta_box() { global $custom_meta_fields, $post; // Use nonce for verification echo ''; // Begin the field table and loop echo '
';
switch($field['type']) {
// text
case 'text':
echo '
'.$field['desc'].''; break; // textarea case 'textarea': echo ' '.$field['desc'].''; break; // checkbox case 'checkbox': echo ' '; break; // select case 'select': echo ' '.$field['desc'].''; break; // radio case 'radio': foreach ( $field['options'] as $option ) { echo ' '; } echo ''.$field['desc'].''; break; // checkbox_group case 'checkbox_group': foreach ($field['options'] as $option) { echo ' '; } echo ''.$field['desc'].''; break; // tax_select case 'tax_select': echo ' Manage '.$taxonomy->label.''; break; // post_list case 'post_list': $items = get_posts( array ( 'post_type' => $field['post_type'], 'posts_per_page' => -1 )); echo ' '.$field['desc'].''; break; // date case 'date': echo ' '.$field['desc'].''; break; // slider case 'slider': $value = $meta != '' ? $meta : '0'; echo ' '.$field['desc'].''; break; // image case 'image': $image = get_template_directory_uri().'/images/image.png'; echo ' '; if ($meta) { $image = wp_get_attachment_image_src($meta, 'medium'); $image = $image[0]; } echo ' Remove Image '.$field['desc'].''; break; // repeatable case 'repeatable': echo '+
|