Skip to content

Instantly share code, notes, and snippets.

@leanda
Created April 13, 2013 19:45
Show Gist options
  • Save leanda/5379767 to your computer and use it in GitHub Desktop.
Save leanda/5379767 to your computer and use it in GitHub Desktop.
WordPress: Conditional Meta Box
function create_meta_box() {
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
$template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
// check for a template type
if ($template_file == 'homepage.php') {
// add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args );
add_meta_box( 'new_meta_box', 'Home Page Blockquote', 'new_meta_box', 'page', 'side', 'low' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment