Skip to content

Instantly share code, notes, and snippets.

@iansvo
Created October 8, 2022 01:57
Show Gist options
  • Save iansvo/5f3a81762b9596f3ca0ca214d1fac49d to your computer and use it in GitHub Desktop.
Save iansvo/5f3a81762b9596f3ca0ca214d1fac49d to your computer and use it in GitHub Desktop.
Add frontend styles to the Gutenberg editor
<?php
/*
* See: https://developer.wordpress.org/reference/functions/add_editor_style/
*
*/
add_action('admin_init', function() {
// Enable support for editor styles
add_theme_support('editor-style');
add_editor_style('dist/css/your-css-file.css'); // Replace path to your frontend stylesheet
});
@iansvo
Copy link
Author

iansvo commented Jul 31, 2023

As of this comment, if your stylesheet contains container queries, it will not be correctly added using this approach. I'm pretty sure this is a bug, see this stackoverflow post: https://wordpress.stackexchange.com/questions/415275/add-editor-style-not-working-after-upgrade-to-wp-v-6-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment