How to enable the block editor for posts and pages without changing the overall theme structure
đź› 1. Edit your functions.php
file
Add the following code at the bottom of functions.php
(before the closing PHP tag if it exists):
// Enable block editor support in TimesNews theme
add_theme_support( 'editor-styles' );
add_theme_support( 'wp-block-styles' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'align-wide' );
// Optional: add custom editor stylesheet if needed
// add_editor_style( 'editor-style.css' );
// Ensure Gutenberg is enabled even if theme disables it
add_filter( 'use_block_editor_for_post', '__return_true' );
🔍 2. Check if Anything Disables Gutenberg
Make sure the theme or a plugin does NOT contain this line:
add_filter( 'use_block_editor_for_post', '__return_false' );
If it does — delete or comment it out.
đź› 3. Create an editor-style.css
file (if you haven’t yet)
In your theme folder (wp-content/themes/timesnews/
), create a file called:
editor-style.css
And add something like:
/* editor-style.css */
body.block-editor-page {
background: #fff;
}
.editor-styles-wrapper {
max-width: 800px; /* You can adjust this to fit your theme */
margin: 0 auto;
padding: 2rem;
background: #fff;
font-family: 'Open Sans', sans-serif;
line-height: 1.6;
}
đź’ˇ Adjust max-width
if your theme’s layout is wider or narrower.
đź› 4. Enqueue the Editor Style in functions.php
Edit your functions.php
and make sure you’ve included this line (you already might have):
add_theme_support( 'editor-styles' );
add_editor_style( 'editor-style.css' );
Together with:
add_theme_support( 'wp-block-styles' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'align-wide' );