Skip to content

Instantly share code, notes, and snippets.

@mattiasghodsian
Last active April 28, 2023 08:33
Show Gist options
  • Save mattiasghodsian/656a8aed08a0601650ea7ddb9ccaaacc to your computer and use it in GitHub Desktop.
Save mattiasghodsian/656a8aed08a0601650ea7ddb9ccaaacc to your computer and use it in GitHub Desktop.
[WordPress] Remove Page content editor for specific template
/**
* Title: Remove Page content editor for specific template
* Author: Mattias Ghodsian
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*/
add_action('admin_init', 'mg_remove_editor_init');
function mg_remove_editor_init() {
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
$template = get_post_meta( $post_id, '_wp_page_template', true );
$template = str_replace('templates/', '', $template);
if($template == 'landing.php'){
remove_post_type_support('page', 'editor');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment