Site logo

[Support request] Is it possible to change the editor width when a full width page element applies

Home Forums Support [Support request] Is it possible to change the editor width when a full width page element applies

Home Forums Support Is it possible to change the editor width when a full width page element applies

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2093416
    Gary

    Hi Support

    I understand that when an element layout applies the editor takes on the width settings. This is fine when I want to use it on pages for example to build a page manually with GB. However I have a scenario on a site I’m currently building where I’ve applied the full width page layout element to another custom post type (case studies).

    I’ve created a content template block element to design the content of the single case study post, so I’m using the full width element so I can add containers which span full width etc to have some different colour sections on the post.

    However when it comes to edit the content of a case study in the block editor it now spans the full width which doesn’t look good from a content editing point of view. I’d like to reduce the width in the editor view as the end client will just populate the text so I want my content template to control the post’s grid/layout design.

    Hope this makes sense?

    Thanks

    #2093544
    Ying
    Staff
    Customer Support

    Hi Gary,

    Try this PHP snippet:

    add_action( 'admin_footer', 'infoauto_editor_width' );
    function infoauto_editor_width() {
    	echo '<style>.post-type-post .editor-styles-wrapper {
        max-width: 900px !important;
        margin-right: auto !important;
        margin-left: auto !important;
    }</style>';
    }

    Try change .post-type-post to your custom post type name.

    You should be able to find this class in the body tag of the single CPT editor.

    #2093636
    Gary

    Hi Ying

    Thanks that snippet does the trick thank you!

    In the meantime I had found this filter via another post: generate_block_editor_content_width

    I couldn’t work out how to target just the case study post type with it. Your snippet works well anyway but just curious if you know if it would be possible with this filter as well?

    Thanks

    #2093673
    Ying
    Staff
    Customer Support

    I’m glad the snippet works.

    The filter works for all editor 🙂 But I’m not sure how to target only the CPT’s editor.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.