Changing Gutenberg / WP block editor width only on pages, not posts or other taxonomies


I have managed to change the width of the WordPress block editor so it uses my max width of my actual theme, making it easier to do layouts during the writing process. Now I wanted to change that to only happen when I edit pages, not posts or other taxonomies.

How do I do that?

My current procedure is:

Add these lines to my theme´s functions.php file:

add_theme_support( 'editor-styles' ); 
add_editor_style( 'style-editor.css' ); 

Then add this css to my style-editor.css file:

@media (min-width: 600px) {

  /* Main column width */
  .wp-block { width: 90%; max-width: 1170px; }

  /* Width of "wide" blocks */
  .wp-block[data-align="wide"] { max-width: 1170px; }

  /* Width of "full-wide" blocks */
  .wp-block[data-align="full"] { max-width: none; }


So far so good, the block editor displays the new width, but when I add the filter for making this only on pages, with what I assume is is_page, it does not work and I end up getting the normal wp editor width. Here is the code in functions.php:

if ( is_page() ) {

    add_theme_support( 'editor-styles' );
    add_editor_style( 'style-editor.css' );


I guess my problem is that I am using the front-end is_page hook, but I cannot find the wp editor equivalent of that. What is the proper code?

, , , , andyNilson 4 years 2020-03-03T15:50:51-05:00 0 Answers 95 views 0

Leave an answer