• Resolved antonop4u

    (@antonop4u)


    I wrote this code to disablem the block editor except on a single custom post type:

    function ppt_custom_post_type_editor( $args, $post_type ) {
    if ( $post_type === 'custom-post-type-slug' ) {
    return true;
    } else {
    return false;
    }
    }
    add_filter( 'use_block_editor_for_post_type', 'ppt_custom_post_type_editor', 10, 2 );

    The problem is that the block editor now doesn’t appaer even in the custom post type it is supposed to show…

    I checked the custom post type slug and it’s correct.

    Does anyone know what I’m doing wrong?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Make sure you are having show_in_rest set to true and support set to at least editor in the CPT registration, and then you don’t need to have the above code ‘use_block_editor_for_post_type’

    Like this :

    'show_in_rest' => true,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ).

    Complete CPT Registration Code Example :

    function cw_post_type() {

    register_post_type( 'portfolio',
    // WordPress CPT Options Start
    array(
    'labels' => array(
    'name' => __( 'Portfolio' ),
    'singular_name' => __( 'Portfolio' )
    ),
    'has_archive' => true,
    'public' => true,
    'rewrite' => array('slug' => 'portfolio'),
    'show_in_rest' => true, // this is a must
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ) // at least array('editor') should be there
    )
    );
    }

    add_action( 'init', 'cw_post_type' );
    Thread Starter antonop4u

    (@antonop4u)

    Yes that’s was the problem, thank you very much now it works perfectly!!!

    Great to help you.

    Kindly mark the post as RESOLVED.

    Moderator bcworkz

    (@bcworkz)

    Marked topic resolved

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.