Created
December 19, 2016 22:33
-
-
Save everaldomatias/8b266e6f8a010af44b38219c4d6f8c3b to your computer and use it in GitHub Desktop.
Conditional Metabox to Page Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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