Created
October 25, 2018 09:15
-
-
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
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
<?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