Skip to content

Instantly share code, notes, and snippets.

@itzikbenh
Forked from danyj/thz_disable_gutenberg.php
Created October 31, 2018 13:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itzikbenh/64052fa7d706ce7550efe95d712a7a94 to your computer and use it in GitHub Desktop.
Save itzikbenh/64052fa7d706ce7550efe95d712a7a94 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