• Resolved rose18

    (@rose18)


    Hi,

    Is there a way to add a custom body classname to the admin block editor pages?

    I don’t want it to be added to other admin pages (such as the dashboard overview page, Settings page, etc.), but only to pages that uses the block editor. I tried this code below, but it’s adding the class name to all the page in the admin. I just want it to be added to the block editor pages.

    add_filter('admin_body_class','my_custom_admin_block_editor_body_class');
    
    function my_custom_admin_block_editor_body_class($classes) {
      $classes .= ' my-block-editor-classname';
      return $classes;
    }

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Every admin screen has a unique ID that can be determined from get_current_screen()->id.

    Thread Starter rose18

    (@rose18)

    I actually use this code to check if current admin page is block editor:

    $current_screen = get_current_screen();
    if ( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() ) {
        // DO SOMETHING
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add custom body class name to admin block editor’ is closed to new replies.