Skip to content

Instantly share code, notes, and snippets.

@rhcarlosweb
Created December 20, 2022 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhcarlosweb/72a3d642b0d1e5d7ab016ac4da5d1c49 to your computer and use it in GitHub Desktop.
Save rhcarlosweb/72a3d642b0d1e5d7ab016ac4da5d1c49 to your computer and use it in GitHub Desktop.
remove gutenbrger by template
/**
* Templates and Page IDs without editor
*/
function ea_disable_editor( $id = false ) {
$excluded_templates = array(
'front-page.php',
);
$excluded_ids = array(
// get_option( 'page_on_front' )
);
if( empty( $id ) )
return false;
$id = intval( $id );
$template = get_page_template_slug( $id );
return in_array( $id, $excluded_ids ) || in_array( $template, $excluded_templates );
}
/**
* Disable Gutenberg by template
*/
function ea_disable_gutenberg( $can_edit, $post_type ) {
if( ! ( is_admin() && !empty( $_GET['post'] ) ) )
return $can_edit;
if( ea_disable_editor( $_GET['post'] ) )
$can_edit = false;
return $can_edit;
}
add_filter( 'gutenberg_can_edit_post_type', 'ea_disable_gutenberg', 10, 2 );
add_filter( 'use_block_editor_for_post_type', 'ea_disable_gutenberg', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment