Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save everaldomatias/8b266e6f8a010af44b38219c4d6f8c3b to your computer and use it in GitHub Desktop.
Save everaldomatias/8b266e6f8a010af44b38219c4d6f8c3b to your computer and use it in GitHub Desktop.
Conditional Metabox to Page Template
<?php
if ( is_admin() && !empty( $_POST['post_ID'] ) ) {
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
$template_file = get_post_meta( $post_id,'_wp_page_template',TRUE );
if ( $template_file == 'page_custom_template.php' ) {
add_action( 'init', 'custom_metabox', 1 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment