How do I load css in edit screens for the block builder?

To load a custom stylesheet for the WordPress admin screens that manage posts and use the block editor, you can use the admin_enqueue_scripts hook to enqueue your stylesheet. Here’s an example of how you can achieve this:

First, create a custom stylesheet (let’s call it admin-custom-styles.css) and place it in your theme or plugin directory.

Open your theme’s functions.php file or create a custom plugin file (e.g., custom-admin-styles.php).

Add the following code to enqueue your custom stylesheet:


function enqueue_custom_admin_styles() {
$current_screen = get_current_screen();

// Check if the current screen is a post editing screen and uses the block editor
if (is_admin() && $current_screen->post_type === 'post' && function_exists('use_block_editor_for_post') && use_block_editor_for_post($current_screen)) {
    // Enqueue your custom stylesheet
    wp_enqueue_style('admin-custom-styles', get_template_directory_uri() . '/path-to-your-admin-custom-styles.css');
}

}
add_action('admin_enqueue_scripts', 'enqueue_custom_admin_styles');


Make sure to replace ‘path-to-your-admin-custom-styles.css’ with the actual path to your custom stylesheet.

This code checks whether the current screen is an admin screen for editing posts and if the block editor is being used. If both conditions are met, it enqueues your custom stylesheet.

Remember to customize the conditions based on your specific requirements, such as the post type and any other conditions you may need.

Once you’ve added this code, your custom stylesheet should be loaded on the specified admin screens, helping you reduce the apparent differences between the admin screens and the actual posts.

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino