Skip to content

Instantly share code, notes, and snippets.

@thierrypigot
Created October 31, 2018 10:00
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 thierrypigot/d71f8ca2c5b0bbceb62eb34f75b0a3ad to your computer and use it in GitHub Desktop.
Save thierrypigot/d71f8ca2c5b0bbceb62eb34f75b0a3ad to your computer and use it in GitHub Desktop.
Disable Gutenberg in WordPress 5.0
<?php
/*
Plugin Name: WeAreWP Gutenberg
Description: Disable Gutenberg in WordPress 5.0
Plugin URI: https://www.wearewp.pro
Version: 1.0
Author: WeAre[WP]
Author URI: https://www.wearewp.pro
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Cannot access pages directly.' );
}
/**
*
* Disbale Gutenberg only for All Custom Post Type
*
**/
// Newer versions of Gutenberg (4.1+), and WordPress 5.0 beta
add_filter('use_block_editor_for_post', '__return_false');
// Older versions of Gutenberg (less than 4.1), and WordPress versions less than 5.0 beta
add_filter('gutenberg_can_edit_post_type', '__return_false');
/** ---------------------------------------------------------------------------------- **/
/**
*
* Disbale Gutenberg only for Custom Post Type Testinonial
*
**/
// Newer versions of Gutenberg (4.1+), and WordPress 5.0 beta
add_filter('use_block_editor_for_post_type', 'wearewp_disable_gutenberg', 10, 2);
// Older versions of Gutenberg (less than 4.1), and WordPress versions less than 5.0 beta
add_filter('gutenberg_can_edit_post_type', 'wearewp_disable_gutenberg', 10, 2);
function wearewp_disable_gutenberg( $is_enabled, $post_type ) {
// Change testimonial to your post type
if ($post_type === 'testimonial'){
return false;
}
return $is_enabled;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment