{"id":46635,"date":"2026-10-10T17:17:35","date_gmt":"2026-10-10T17:17:35","guid":{"rendered":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/?p=46635"},"modified":"2026-10-10T17:17:35","modified_gmt":"2026-10-10T17:17:35","slug":"disable-gutenberg-for-specific-post-types","status":"publish","type":"post","link":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/disable-gutenberg-for-specific-post-types\/","title":{"rendered":"Disable Gutenberg for Specific Post Types in WordPress"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Disabling Gutenberg for specific post types in WordPress is a common need when a custom post type is mostly custom fields. A block canvas adds nothing there, and meta boxes fit better on the classic screen. The Classic Editor plugin switches the whole site, which is more than you want.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This snippet keeps the block editor for posts and pages and opens the classic editor only for the post types you list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The snippet<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php\nadd_filter( 'use_block_editor_for_post_type', 'dpc_disable_block_editor_for_post_types', 10, 2 );\n\n\/**\n * Use the classic editor for the listed post types.\n *\/\nfunction dpc_disable_block_editor_for_post_types( $use_block_editor, $post_type ) {\n\t$classic_post_types = array( 'book', 'movie' );\n\n\tif ( in_array( $post_type, $classic_post_types, true ) ) {\n\t\treturn false;\n\t}\n\n\treturn $use_block_editor;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Add it with Scripts Organizer<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/dplugins.com\/downloads\/scripts-organizer\/\">Scripts Organizer<\/a> ships this snippet in its One-Click Import library. To add it by hand:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In wp-admin go to <strong>Scripts Organizer \u2192 Code Blocks \u2192 Add New<\/strong> and give the block a title.<\/li>\n\n\n<li><strong>Script location<\/strong>: PHP.<\/li>\n\n\n<li><strong>Trigger location<\/strong>: Admin only. The editor screen is part of wp-admin, so the code does not need to load on the front end.<\/li>\n\n\n<li><strong>Action hook<\/strong>: leave it empty. The code only registers filters and actions, so it can run while plugins load.<\/li>\n\n\n<li>Paste the snippet into the PHP editor, enable the block and publish it.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The same code also works unchanged in a small plugin or an mu-plugin file in <code>wp-content\/mu-plugins\/<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How it works<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress calls the <code>use_block_editor_for_post_type<\/code> filter when it decides which editor to load on <code>post.php<\/code> and <code>post-new.php<\/code>, and when it builds edit links in the admin. Returning <code>false<\/code> for a post type sends every post of that type to the classic editor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For every other type the snippet returns the value it received instead of <code>true<\/code>. A decision made earlier by WordPress or another plugin, such as a post type without REST support, is kept.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The strict <code>in_array()<\/code> comparison avoids type juggling, and the function only compares slugs, so it costs nothing on admin requests.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Customise it<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>book<\/code> and <code>movie<\/code> with your own slugs. The slug is the first argument of <code>register_post_type()<\/code>, and it is also the <code>post_type<\/code> value in the URL of the list screen, for example <code>edit.php?post_type=book<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To switch single posts rather than a whole type, use the <code>use_block_editor_for_post<\/code> filter. This example keeps the classic editor for pages that use a landing page template:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_filter( 'use_block_editor_for_post', 'dpc_classic_editor_for_landing_pages', 10, 2 );\n\nfunction dpc_classic_editor_for_landing_pages( $use_block_editor, $post ) {\n\tif ( 'templates\/landing.php' === get_page_template_slug( $post ) ) {\n\t\treturn false;\n\t}\n\n\treturn $use_block_editor;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Gotchas<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A post type registered with <code>show_in_rest<\/code> set to <code>false<\/code> already uses the classic editor, because the block editor needs the REST API.<\/li>\n\n\n<li>Content written in the block editor keeps its block comments. The classic editor shows them as HTML comments in the Text tab; leave them in place if you may switch back later.<\/li>\n\n\n<li>This only changes the post editor. The Site Editor, the widgets screen and template editing are separate screens.<\/li>\n\n\n<li>If you only want a lighter block editor rather than none, see <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/disable-default-block-theme-patterns\/\">Disable default block theme patterns<\/a>.<\/li>\n\n<\/ul>\n\n","protected":false},"excerpt":{"rendered":"<p>Turn off the Gutenberg block editor for chosen post types in WordPress and use the classic editor for them, while posts and pages keep blocks.<\/p>\n","protected":false},"author":1,"featured_media":46636,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Disable Gutenberg for Specific Post Types in WordPress","description":"Turn off the Gutenberg block editor for chosen post types in WordPress and use the classic editor for them, while posts and pages keep blocks."},"_slim_seo_primary_term_category":0,"_slim_seo_primary_term_post_tag":0,"footnotes":""},"categories":[90,3],"tags":[159,181,141,121],"dpc_library":[204],"class_list":["post-46635","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gutenberg","category-wordpress","tag-block-editor","tag-classic-editor","tag-custom-post-types","tag-gutenberg"],"_links":{"self":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46635","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/comments?post=46635"}],"version-history":[{"count":1,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46635\/revisions"}],"predecessor-version":[{"id":46662,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46635\/revisions\/46662"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media\/46636"}],"wp:attachment":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media?parent=46635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/categories?post=46635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/tags?post=46635"},{"taxonomy":"dpc_library","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/dpc_library?post=46635"}],"curies":[{"name":"wp","href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/api.w.org\/{rel}","templated":true}]}}