I'd like to modify the admin so the default text editor is removed whenever someone is using the default template. (If they manually choose something other than the default, keep the editor).

if ($currentPage == 'Default Template') {
  remove_post_type_support( 'page', 'editor' );

So I am looking for a way to determine the selected page template on load and perform an action based on that. I am trying to do something If I run this query:

add_action('init', function () { 



On a new theme it returns an array with template-custom.blade.php. But when I run this:

add_action('init', function () { 



It returns page.php. If I switch the page to "Custom Template" and save. Even on reload it still returns page.php. What are my options?

I also tried this method in init didn't work either.

$template_filename = get_post_meta( get_the_ID(), '_wp_page_template', true );

AFAIK, I should remove_post_type_support during the init hook, but wondering if the template information is available yet.

1 Answer 1


I picked the following code from an answer here, https://stackoverflow.com/questions/2544870/remove-main-editor-from-wordpress-edit-page-screen/42093956. I tweaked the code to remove the classic editor on pages using default page template. And added the comments.

function remove_editor_init() {
  $post_id = 0;
  if ( isset( $_GET['post'] ) ) {
    $post_id = $_GET['post'];
  $template_file = get_post_meta( $post_id, '_wp_page_template', TRUE );
  // var_dump($template_file) to see which template the page is using
  // no value on new pages and when template haven't been changed yet
  // default if changed back to default template
  if ( ! $template_file || 'default' === $template_file ) {
    remove_post_type_support( 'page', 'editor' );
add_action( 'admin_init', 'remove_editor_init' );

This worked on my local WP install, perhaps you could give it a try?

  • Worked perfectly, thank you.
    – Nathan
    Jun 30, 2019 at 0:30
  • Genius idea, looking for the $post _id in the $GET object rather than the global $post object (which wasn't appearing for me on admin_init) Oct 19, 2020 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.