Skip to content
  • Quick Ref
  • Contact
  • About
wpcanyon.com

wpcanyon.com

Tag: Classic Editor

Disable Gutenberg for specific post types

Posted on August 19, 2025 By Admin No Comments on Disable Gutenberg for specific post types

Disable Gutenberg for Specific Post Types

If you want to disable the Gutenberg block editor for certain post types in WordPress, this quick guide will show you how. By default, Gutenberg is enabled for all post types that support the editor, but sometimes you need to revert to the classic editor or a custom meta box interface for specific post types. The fix is simple: add a small code snippet to your theme or plugin to disable Gutenberg selectively.

Quick Fix

  1. Identify the post types where you want to disable Gutenberg.
  2. Add a PHP filter to disable Gutenberg for those post types.
  3. Place the code in your theme’s functions.php file or a custom plugin.
  4. Clear caches and test the post editor for the specified post types.

Why This Happens

Gutenberg is WordPress’s default block editor introduced in version 5.0. It automatically activates for all post types that declare support for the editor. However, some custom post types or legacy content require the classic editor or a different editing interface. WordPress does not provide a built-in UI to disable Gutenberg on a per-post-type basis, so developers must use filters to control its activation.

Requirements

  • WordPress 5.0 or higher with Gutenberg enabled.
  • Access to your theme’s functions.php file or ability to create a custom plugin.
  • Basic knowledge of PHP and WordPress hooks.

Step-by-step: Disable Gutenberg for Specific Post Types

  1. Open your theme’s functions.php file or create a custom plugin file.
  2. Insert the following PHP code snippet:
<?php
/**
 * Disable Gutenberg editor for specific post types.
 *
 * @param bool   $is_enabled Whether the editor is enabled.
 * @param string $post_type  The post type being checked.
 * @return bool
 */
function disable_gutenberg_for_post_types( $is_enabled, $post_type ) {
    // List post types to disable Gutenberg for
    $disabled_post_types = array( 'your_post_type', 'another_post_type' );

    if ( in_array( $post_type, $disabled_post_types, true ) ) {
        return false; // Disable Gutenberg
    }

    return $is_enabled; // Keep default behavior for others
}
add_filter( 'use_block_editor_for_post_type', 'disable_gutenberg_for_post_types', 10, 2 );
  1. Replace your_post_type and another_post_type with your actual post type slugs.
  2. Save the file and upload it to your server if editing locally.
  3. Clear any caching plugins or server caches.
  4. Test by editing a post of the specified post types; the classic editor or meta boxes should appear instead of Gutenberg.

Additional Tips

  • If you want to disable Gutenberg for all custom post types, you can modify the code to check if the post type is not ‘post’ or ‘page’.
  • To disable Gutenberg for all post types, return false unconditionally in the filter.

Common Pitfalls

  • Incorrect post type slug: Make sure you use the exact post type slug registered in WordPress.
  • Code placement: Adding the code in the wrong place (e.g., outside PHP tags) will cause errors.
  • Conflicts with plugins: Some plugins override editor settings; test with plugins disabled if issues arise.
  • Caching: Browser or server caching might show the old editor; clear caches after changes.
  • Editor support: This method only works if the post type supports the editor feature.

Works on

  • Web servers: Apache, Nginx, LiteSpeed
  • Control panels: cPanel, Plesk, DirectAdmin
  • WordPress environments with PHP 7.0+ (recommended 7.4+)
  • Any WordPress theme or plugin setup where you can add PHP code

FAQ

Question Answer
Can I disable Gutenberg only for posts but keep it for pages? Yes. Use the code snippet and set $disabled_post_types = array('post'); to disable Gutenberg only for posts.
Will this code affect the REST API? No. This filter only controls the editor interface in the admin area. The REST API remains unaffected.
How do I find the post type slug? You can find it in the post type registration code or by inspecting the URL when editing a post (e.g., post.php?post=123&post_type=your_post_type).
Can I disable Gutenberg for all custom post types automatically? Yes. Modify the function to check if the post type is not ‘post’ or ‘page’ and return false accordingly.
Is there a plugin alternative to this code? Yes, plugins like “Classic Editor” or “Disable Gutenberg” offer UI options to disable Gutenberg per post type without coding.
…
Admin & Blocks

Recent Posts

  • Top WordPress Themes for Blogs in 2025
  • WordPress Admin Panel Trick: Adding ID Field to the Posts Listing
  • Solution previous_posts_link and next_posts_link Not Working
  • Show Top Commentators in WordPress Without a Plugin
  • How to Style Admin Comments in WordPress

Recent Comments

    Archives

    • August 2025

    Categories

    • Admin & Blocks
    • Admin & UI
    • Automation
    • Automation & Plugins
    • Comments
    • Comparisons
    • Database & Revisions
    • Developer Snippets
    • Fixes & Errors
    • Media & Thumbnails
    • Queries & Pagination
    • Security
    • Speed & Security
    • Tips & Tricks
    • WooCommerce How‑tos
    • WordPress Snippets
    • WordPress Themes
    • Terms & Conditions
    • Affiliate Disclosure

    Copyright © 2025 wpcanyon.com.

    Powered by PressBook WordPress theme

    Also by the maker of MySurveyReviews.com