Include Bootstrap 5 CSS (and JS) in the new site editor
-
Hello,
Thanks for your support beforehand.
I am developing a block theme. I want to include Bootstrap 5 framework CSS (and JS) files in the new site editor. In order to use Bootstrap classes and see the result live in the site editor both for me and the end user.
I used this method to add the Bootstrap CSS file in WordPress admin section:/* Enqueue custom-bootstrap.css in the WordPress admin on site-editor.php */ function admin_bootstrap_style($hook) { if ('site-editor.php' != $hook) { return; } wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/custom-bootstrap.css', array(), wp_get_theme()->get('Version') ); } add_action('admin_enqueue_scripts', 'admin_bootstrap_style');
It loads the stylesheet in site-editor.php but when I add a class to a block, it does not show the preview section in the site editor even if the class is actually added to the codes. But when I go website front-end, the result is correctly shown.
I want the same experience for both the editor (back-end) and front-end (what the user sees when opening the site). This way, the site owner can better edit the theme in the editor.
Thanks again.The page I need help with: [log in to see the link]
- The topic ‘Include Bootstrap 5 CSS (and JS) in the new site editor’ is closed to new replies.