kalponikoronno

OPTION TREE META BOX FOR SPECIFIC TEMPLATE

Feb 27th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.45 KB | None | 0 0
  1. <?php
  2.  
  3. add_action( 'admin_init', 'custom_meta_boxes' );
  4.  
  5. function custom_meta_boxes() {
  6.  
  7.  
  8.    
  9. /****************META BOX FOR SPECIFIC TEMPLATE START**********************/
  10.  
  11. ot_register_meta_box( $meta_template_data_box );
  12.  
  13.   $meta_template_data_box = array(
  14.     'id'          => 'meta_template_data_box',
  15.     'title'       => __( 'Demo Meta Box', 'theme-text-domain' ),
  16.     'desc'        => '',
  17.     'pages'       => array( 'page' ),
  18.     'context'     => 'normal',
  19.     'priority'    => 'high',
  20.     'fields'      => array(
  21.  
  22.       array(
  23.         'label'       => __( 'Textarea', 'theme-text-domain' ),
  24.         'id'          => 'demo_textarea',
  25.         'type'        => 'textarea',
  26.         'desc'        => __( 'This is a demo Textarea field.', 'theme-text-domain' )
  27.       )
  28.      
  29.     )
  30.   );
  31.  
  32. $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
  33. $template_file = get_post_meta($post_id, '_wp_page_template', TRUE);
  34.  
  35. if ($template_file == 'about-page.php') {
  36.     ot_register_meta_box( $meta_template_data_box );
  37. }  
  38.    
  39. /****************META BOX FOR SPECIFIC TEMPLATE END**********************/
  40.  
  41.  
  42.  
  43.  
  44. /****************META BOX FOR SPECIFIC SLIDER CUSTOM POST**********************/
  45.   $slider_meta_box = array(
  46.     'id'          => 'slidername_meta_box',
  47.     'title'       => __( 'Slider title', 'theme-text-domain' ),
  48.     'desc'        => '',
  49.     'pages'       => array( 'slider' ),
  50.     'context'     => 'normal',
  51.     'priority'    => 'high',
  52.     'fields'      => array(
  53.       array(
  54.         'label'       => __( 'Enter your slider title', 'theme-text-domain' ),
  55.         'id'          => 'slider_title',
  56.         'type'        => 'text'
  57.       ),
  58.       array(
  59.         'label'       => __( 'Show your name', 'theme-text-domain' ),
  60.         'id'          => 'name_title',
  61.         'type'        => 'text'
  62.       ),
  63.       array(
  64.         'label'       => __( 'Subtitle', 'theme-text-domain' ),
  65.         'id'          => 'slsub_title',
  66.         'type'        => 'text'
  67.       ),
  68.       array(
  69.         'label'       => __( 'your thumbnail image', 'theme-text-domain' ),
  70.         'id'          => 'postimageurl',
  71.         'type'        => 'text'
  72.       ),
  73.  
  74.     )
  75.   );
  76.  
  77.   /**
  78.    * Register our meta boxes using the
  79.    * ot_register_meta_box() function.
  80.    */
  81.   if ( function_exists( 'ot_register_meta_box' ) )
  82.     ot_register_meta_box( $slider_meta_box );
  83.  
  84. /****************META BOX FOR SPECIFIC SLIDER POST END**********************/
  85.  
  86.  
  87.    
  88. }
  89.  
  90. ?>
Advertisement
Add Comment
Please, Sign In to add comment