If you want to disable it globally, you can use this code:
1 2 3 4 5 6 7 |
if ( version_compare($GLOBALS['wp_version'], '5.0-beta', '>') ) { // WP > 5 beta add_filter( 'use_block_editor_for_post_type', '__return_false', 100 ); } else { // WP < 5 beta add_filter( 'gutenberg_can_edit_post_type', '__return_false' ); } |
And if you want to disable it only for given post type, you can use:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
function my_disable_gutenberg_for_post_type( $is_enabled, $post_type ) { if ( 'page' == $post_type ) { // disable for pages, change 'page' to you CPT slug return false; } return $is_enabled; } if ( version_compare($GLOBALS['wp_version'], '5.0-beta', '>') ) { // WP > 5 beta add_filter( 'use_block_editor_for_post_type', 'my_disable_gutenberg_for_post_type', 10, 2 ); } else { // WP < 5 beta add_filter( 'gutenberg_can_edit_post_type', 'my_disable_gutenberg_for_post_type', 10, 2 ); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.