Make WordPress Core

Opened 17 months ago

Closed 17 months ago

Last modified 17 months ago

#50151 closed defect (bug) (invalid)

use_block_editor_for_post_type filter always returns page or post as post_type

Reported by: dingo_d Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.5
Component: Editor Keywords:
Focuses: Cc:


I'm trying to enable the core editor only for one post type on a client project (want to transition to blocks piece by piece). So I've added the use_block_editor_for_post_type filter, and set:

   * Register hooks
  public function register() : void {
    add_filter( 'use_block_editor_for_post_type', [ $this, 'disable_gutenberg' ], 10, 2 );

  public function disable_gutenberg( bool $use_block_editor, string $post_type ) {
    if ( in_array( $post_type, [ 'post', 'page' ], true ) ) {
      return false;

    return $use_block_editor;

And I check posts, and pages, they don't have GB (which is what I want). But my custom post types, which have editor enabled, also show classic editor.

So I added an error_log in the filter and all the $post_type variable value when I'm at the new page of the CPT is page (except when I'm on a post, then it's post).

Is this a bug or?

Change History (2)

#1 @dingo_d
17 months ago

  • Resolution set to invalid
  • Status changed from new to closed

My bad, I didn't notice that show_in_rest parameter was set to false in my CPTs 🤦🏼‍♂️

#2 @SergeyBiryukov
17 months ago

  • Component changed from General to Editor
  • Keywords 2nd-opinion removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.