Skip to content

Instantly share code, notes, and snippets.

@matthacksteiner
Last active October 15, 2020 10:09
Show Gist options
  • Save matthacksteiner/8ddbd789ce1b1bc84d69ba3b4d84ff53 to your computer and use it in GitHub Desktop.
Save matthacksteiner/8ddbd789ce1b1bc84d69ba3b4d84ff53 to your computer and use it in GitHub Desktop.
// remove meta box on custom template CUSTOM
add_action('init', 'remove_editor_CUSTOM');
function remove_editor_CUSTOM()
{
if (!is_admin()) {
return;
}
$current_post_id = filter_input(INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT);
$update_post_id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT);
if (isset($current_post_id)) {
$post_id = absint($current_post_id);
} else if (isset($update_post_id)) {
$post_id = absint($update_post_id);
} else {
return;
}
if (isset($post_id)) {
$template_file = get_post_meta($post_id, '_wp_page_template', true);
if ('templates/page-CUSTOM.php' === $template_file) {
// remove_meta_box('pageparentdiv', 'page', 'side');
// remove_post_type_support('page', 'editor');
// remove_post_type_support('page', 'title');
// remove_meta_box('submitdiv', 'page', 'normal');
remove_meta_box('commentstatusdiv', 'page', 'normal');
remove_meta_box('slugdiv', 'page', 'normal');
remove_meta_box('commentsdiv', 'page', 'normal');
remove_meta_box('postexcerpt', 'page', 'normal');
remove_meta_box('authordiv', 'page', 'normal');
// remove_meta_box('revisionsdiv', 'page', 'normal');
remove_meta_box('postcustom', 'page', 'normal');
remove_meta_box('trackbacksdiv', 'page', 'normal');
// remove_meta_box('categorydiv', 'page', 'normal');
remove_meta_box('tagsdiv-post_tag', 'page', 'normal');
remove_meta_box('postimagediv', 'page', 'normal');
remove_meta_box('pageparentdiv', 'page', 'normal');
// remove_post_type_support('page', 'thumbnail');
// remove_post_type_support('page', 'page-attributes');
remove_post_type_support('page', 'excerpt');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment