Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'admin_init', 'custom_meta_boxes' );
- function custom_meta_boxes() {
- /****************META BOX FOR SPECIFIC TEMPLATE START**********************/
- ot_register_meta_box( $meta_template_data_box );
- $meta_template_data_box = array(
- 'id' => 'meta_template_data_box',
- 'title' => __( 'Demo Meta Box', 'theme-text-domain' ),
- 'desc' => '',
- 'pages' => array( 'page' ),
- 'context' => 'normal',
- 'priority' => 'high',
- 'fields' => array(
- array(
- 'label' => __( 'Textarea', 'theme-text-domain' ),
- 'id' => 'demo_textarea',
- 'type' => 'textarea',
- 'desc' => __( 'This is a demo Textarea field.', 'theme-text-domain' )
- )
- )
- );
- $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
- $template_file = get_post_meta($post_id, '_wp_page_template', TRUE);
- if ($template_file == 'about-page.php') {
- ot_register_meta_box( $meta_template_data_box );
- }
- /****************META BOX FOR SPECIFIC TEMPLATE END**********************/
- /****************META BOX FOR SPECIFIC SLIDER CUSTOM POST**********************/
- $slider_meta_box = array(
- 'id' => 'slidername_meta_box',
- 'title' => __( 'Slider title', 'theme-text-domain' ),
- 'desc' => '',
- 'pages' => array( 'slider' ),
- 'context' => 'normal',
- 'priority' => 'high',
- 'fields' => array(
- array(
- 'label' => __( 'Enter your slider title', 'theme-text-domain' ),
- 'id' => 'slider_title',
- 'type' => 'text'
- ),
- array(
- 'label' => __( 'Show your name', 'theme-text-domain' ),
- 'id' => 'name_title',
- 'type' => 'text'
- ),
- array(
- 'label' => __( 'Subtitle', 'theme-text-domain' ),
- 'id' => 'slsub_title',
- 'type' => 'text'
- ),
- array(
- 'label' => __( 'your thumbnail image', 'theme-text-domain' ),
- 'id' => 'postimageurl',
- 'type' => 'text'
- ),
- )
- );
- /**
- * Register our meta boxes using the
- * ot_register_meta_box() function.
- */
- if ( function_exists( 'ot_register_meta_box' ) )
- ot_register_meta_box( $slider_meta_box );
- /****************META BOX FOR SPECIFIC SLIDER POST END**********************/
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment