{"id":1003,"date":"2019-12-06T12:00:00","date_gmt":"2019-12-06T05:00:00","guid":{"rendered":"https:\/\/lab.wptips.dev\/?p=1003"},"modified":"2020-06-21T09:47:53","modified_gmt":"2020-06-21T02:47:53","slug":"disable-gutenberg-without-plugin","status":"publish","type":"post","link":"https:\/\/pixelstudio.id\/blog\/disable-gutenberg-without-plugin\/","title":{"rendered":"How to Disable Gutenberg without Plugin"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote\"><p>Gutenberg (also knows as Block Editor) is the official drag-n-drop builder in WordPress version 5.0+.<\/p><\/blockquote>\n\n\n\n<p>There are a lot of plugins to disable Gutenberg editor. But the <strong>code to disable<\/strong> it is actually very short and simple. So no need for plugin, just add this snippet in your theme&#8217;s functions:<\/p>\n\n\n\n<pre title=\"functions.php\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_filter( 'use_block_editor_for_post', '__return_false' );<\/code><\/pre>\n\n\n\n<p>Yes, I&#8217;m serious. it&#8217;s only that 1 line.<\/p>\n\n\n\n<p>There are cases when you want to enable Gutenberg only in some condition. Below are some common examples:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Allow Gutenberg for Posts Only<\/h2>\n\n\n\n<p>We use the same filter and return true if it&#8217;s on <code>post<\/code> edit page.<\/p>\n\n\n\n<pre title=\"functions.php\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_filter( 'use_block_editor_for_post', 'my_disable_gutenberg', 10, 2 );\n\nfunction my_disable_gutenberg( $can_edit, $post ) {\n  if( $post->post_type == 'post' ) {\n    return true;\n  }\n\n  return false;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Allow for Page with the Template &#8220;Allow Gutenberg&#8221;<\/h2>\n\n\n\n<p>First, create a new Page Template, take note of the file name:<\/p>\n\n\n\n<pre title=\"page-gutenberg.php\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php\n\/**\n * Template Name: Allow Gutenberg\n *\/\n\nrequire_once 'page.php';<\/code><\/pre>\n\n\n\n<p>Then, still using the same filter, add a conditional to check if it&#8217;s using that page template:<\/p>\n\n\n\n<pre title=\"functions.php\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_filter( 'use_block_editor_for_post', 'my_disable_gutenberg', 10, 2 );\n\nfunction my_disable_gutenberg( $can_edit, $post ) {\n  if( $post->post_type == 'page' &amp;&amp;\n    get_page_template_slug( $post->ID ) == 'page-gutenberg.php' ) {\n    return true;\n  }\n\n  return false;\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>There are many reasons to disable Gutenberg. Maybe you already use another Page Builder? Maybe it lacks the control ACF provides?<\/p>\n\n\n\n<p>For <strong>old site<\/strong>, you generally want to fully disable it. But you might want to have a little taste of Gutenberg by enabling it on Blog Post only. You can do so by following the code above.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Let us know why you disable Gutenberg in the comment below \ud83d\ude42<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>There are a lot of plugins to disable Gutenberg editor. But the code to disable it is actually very short and simple. So no need for plugin, just add this snippet in your theme&#8217;s functions:<\/p>\n","protected":false},"author":1,"featured_media":1006,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[22,31],"class_list":["post-1003","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gutenberg","tag-gutenberg","tag-php"],"blocksy_meta":{"page_structure_type":"default","page_enable_vertical_spacing":"yes","has_hero_section":"default","hero_section":"type-1","hero_alignment1":"left","hero_alignment2":"center","hero_height":"230px","page_title_bg_type":"color","3698d5867f2f71c3848747f94bfaf732":"","custom_hero_background":{"attachment_id":null},"parallax":{"desktop":false,"tablet":false,"mobile":false},"56b29e63aaa60504c1c842af1c525f4d":"","single_meta_elements":{"author":true,"date":true,"categories":true,"comments":true,"updated":false,"tags":false},"has_meta_label":"yes","date_format_source":"custom","single_meta_date_format":"M j, Y","06c89f05d90719b223ab1d100d73f59e":"","page_excerpt_visibility":{"desktop":true,"tablet":true,"mobile":false},"pageTitleFont":{"family":"Default","variation":"Default","size":{"desktop":"32px","tablet":"30px","mobile":"25px"},"line-height":"1.3","letter-spacing":"CT_CSS_SKIP_RULE","text-transform":"CT_CSS_SKIP_RULE","text-decoration":"CT_CSS_SKIP_RULE"},"pageTitleFontColor":{"default":{"color":"var(--paletteColor4)"}},"pageMetaFont":{"family":"Default","variation":"n6","size":{"desktop":"12px","tablet":"12px","mobile":"12px"},"line-height":"1.3","letter-spacing":"CT_CSS_SKIP_RULE","text-transform":"uppercase","text-decoration":"CT_CSS_SKIP_RULE"},"pageMetaFontColor":{"default":{"color":"CT_CSS_SKIP_RULEDEFAULT"},"hover":{"color":"CT_CSS_SKIP_RULEDEFAULT"}},"pageExcerptFont":{"family":"Default","variation":"n5","size":"CT_CSS_SKIP_RULE","line-height":"CT_CSS_SKIP_RULE.65","letter-spacing":"CT_CSS_SKIP_RULE","text-transform":"CT_CSS_SKIP_RULE","text-decoration":"CT_CSS_SKIP_RULE"},"pageExcerptColor":{"default":{"color":"CT_CSS_SKIP_RULEDEFAULT"}},"pageTitleOverlay":{"default":{"color":"rgba(41, 51, 60, 0.2)"}},"pageTitleBackground":{"default":{"color":"#EDEFF2"}},"115602695f79337831726b0758ce91f2":"","041fcad2f690ace5bd196b2ff7d44ff0":"","30410f85501210947bb0a461758ba551":""},"_links":{"self":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/1003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/comments?post=1003"}],"version-history":[{"count":7,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/1003\/revisions"}],"predecessor-version":[{"id":1584,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/1003\/revisions\/1584"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/media\/1006"}],"wp:attachment":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/media?parent=1003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/categories?post=1003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/tags?post=1003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}