Halloween Sale 15% off Ends in See the plans
PHP

Use the Classic Editor for Selected Pages or Templates

Opens specific pages, or pages using certain templates, in the classic editor while everything else keeps the block editor.

Don’t have WPIDE yet? Install it on your site

Code

// Post or page IDs that open in the classic editor.
$wpide_classic_editor_ids = array( 0 );
// Page template file names that open in the classic editor.
$wpide_classic_editor_templates = array( 'template-legacy.php' );

add_filter( 'use_block_editor_for_post', function ( $use, $post ) use ( $wpide_classic_editor_ids, $wpide_classic_editor_templates ) {
    if ( ! $post ) {
        return $use;
    }

    if ( in_array( (int) $post->ID, array_map( 'absint', $wpide_classic_editor_ids ), true ) ) {
        return false;
    }

    $template = get_page_template_slug( $post );

    if ( $template && in_array( $template, $wpide_classic_editor_templates, true ) ) {
        return false;
    }

    return $use;
}, 10, 2 );

Notes

List page IDs and template file names, such as template-legacy.php. Requires the classic editor to be available (it is built in for posts that opt out).

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.