Last active
April 28, 2023 08:33
-
-
Save mattiasghodsian/656a8aed08a0601650ea7ddb9ccaaacc to your computer and use it in GitHub Desktop.
[WordPress] Remove Page content editor for specific 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
/** | |
* 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