Skip to content

Instantly share code, notes, and snippets.

@jeremyHixon
Last active December 19, 2018 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyHixon/3a989034d61f324ecb7dc2284c72ed71 to your computer and use it in GitHub Desktop.
Save jeremyHixon/3a989034d61f324ecb7dc2284c72ed71 to your computer and use it in GitHub Desktop.
WordPress 5.0's Gutenberg editor requires enqueuing of the stylesheet as well as adding support for said editor styles before it will work properly.
/**
* Add this into your functions.php file.
*/
/**
* Adding theme support
*/
if ( !function_exists( 'rwp_after_setup_theme' ) ) {
function rwp_after_setup_theme() {
add_theme_support( 'editor-styles' );
}
}
add_action( 'after_setup_theme', 'rwp_after_setup_theme' );
/**
* Adding editor stylesheet
* Replace {stylesheet_uri} with the URI to your editor/Gutenberg stylesheet.
*/
if ( !function_exists( 'rwp_admin_init' ) ) {
function rwp_admin_init() {
add_editor_style( get_theme_file_uri( '{stylesheet_uri}' ) );
}
}
add_action( 'admin_init', 'rwp_admin_init' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment