Skip to content

Instantly share code, notes, and snippets.

@danyj
Created October 25, 2018 09:15
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save danyj/ec00057550fd6f73995ab2f8fc8b729f to your computer and use it in GitHub Desktop.
Save danyj/ec00057550fd6f73995ab2f8fc8b729f to your computer and use it in GitHub Desktop.
Disable Gutenberg globally or for specific post types for WordPress 5.0 and UP
<?php
/*
* Disable Gutenberg globally
* use this if you prefer one-liner
* add_filter('use_block_editor_for_post', '__return_false');
*/
function _thz_filter_disable_block_editor(){
return false;
}
add_filter( 'use_block_editor_for_post', '_thz_filter_disable_block_editor' );
/*
* Disable Gutenberg for specific post types
*/
function _thz_filter_disable_block_editor_pt( $use_block_editor, $post_type ){
if( 'page' == $post_type || 'post' == $post_type){
$use_block_editor = false;
}
return $use_block_editor;
}
add_filter( 'use_block_editor_for_post_type', '_thz_filter_disable_block_editor_pt', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment