Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save webhasan/c9bdbe6f147a261fda13 to your computer and use it in GitHub Desktop.
Save webhasan/c9bdbe6f147a261fda13 to your computer and use it in GitHub Desktop.
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
$template_file = get_post_meta($post_id, '_wp_page_template', TRUE);
if ($template_file == 'welcome.php') {
ot_register_meta_box( $home_page_meta_box );
}
/* -------------------------------------------------------------
so, entire file should looks like this:
------------------------------------------------------------- */
<?php
/**
* Initialize the meta boxes.
*/
add_action( 'admin_init', '_custom_meta_boxes' );
/**
* Meta Boxes demo code.
*
* You can find all the available option types
* in demo-theme-options.php.
*
* @return void
*
* @access private
* @since 2.0
*/
function _custom_meta_boxes() {
/**
* Create a custom meta boxes array that we pass to
* the OptionTree Meta Box API Class.
*/
$header_image = array(
'id' => 'header_overlay_content',
'title' => 'Header Content',
'pages' => array( 'page'),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'label' => 'Header Area',
'id' => 'header_content_overlay',
'type' => 'textarea',
)
)
);
/**
* Register our meta boxes using the
* ot_register_meta_box() function.
*/
ot_register_meta_box( $header_image );
$home_page_meta_box = array(
'id' => 'home_setting',
'title' => 'Home Page Content',
'desc' => '',
'pages' => array( 'page' ),
'context' => 'normal',
'fields' => array(
array(
'label' => 'Location',
'id' => 'location',
'type' => 'text',
'desc' => '',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => ''
),
array(
'label' => 'Registration Link',
'id' => 'register_link',
'type' => 'text',
'desc' => '',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => ''
),
array(
'label' => 'Banner Image Link',
'id' => 'banner_img',
'type' => 'upload',
'desc' => '',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => ''
),
array(
'label' => 'Left Column Content',
'id' => 'left_c',
'type' => 'textarea',
'desc' => '',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => ''
),
array(
'label' => 'Center Column Content',
'id' => 'center_c',
'type' => 'textarea',
'desc' => '',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => ''
),
array(
'label' => 'Right Column Content',
'id' => 'right_c',
'type' => 'textarea',
'desc' => '',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => ''
)
)
);
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
$template_file = get_post_meta($post_id, '_wp_page_template', TRUE);
if ($template_file == 'welcome.php') {
ot_register_meta_box( $home_page_meta_box );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment