Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Show css styles in wordpress editor

  • I have always used a certain php-code, which ensures that all css specifications made in the style.css of the childtheme are also displayed in the editor. This has always worked very well so far.

    add_filter( 'generate_editor_styles', function( $editor_styles ) {
        $editor_styles[] = 'style.css';
        return $editor_styles;
    } );

    Now this suddenly doesn’t work anymore πŸ™
    It looks good in the frontend, but the block-editor no longer adopts the styles.

    Could this have something to do with the new version?

    Thank you

  • Hi there,

    What WP version do you use?

    There some changes in WP 6.5 mess with the way styles loaded in the editor. We are aware of this and currently looking at possible fixes.

  • Hi Alvind,

    thank you for feedback!
    Puuh, does it have to do with the WP version? Yes, I’m using 6.5.2.
    All my pages are broken in the editor now πŸ™

  • Yes, this issue affects WordPress versions 6.5 and above.

    As a workaround for now, you can move your child theme styles to the Customizer’s Additional CSS and use this PHP snippet to load the customizer’s CSS into the editor:

    add_filter( 'block_editor_settings_all', function( $editor_settings ) {
        $css = wp_get_custom_css_post()->post_content;
        $editor_settings['styles'][] = array( 'css' => $css );
    
        return $editor_settings;
    } );
  • Thank you for your feedback.

    I also know the code you mentioned.
    I have already tried it, but unfortunately that doesn’t work either!

  • My apologies for that! I was testing on one of my local test sites, and it turns out the site is running WP version 6.4.3. It seems that the snippet is also not working anymore on WP 6.5.

  • Hello again,

    I have now posted this question in the WP Support forum, because a correct appearance in the editor is very important to me. Since I format a lot via style.css, it now looks like a mess in my editor πŸ˜•

    This is the answer I got: https://prnt.sc/ioESw7nv8OHJ

    Can you help? Thank you very much!

  • Hi there,

    can i see the site you’re having the issue with ?
    For reference WP 6.5 introduced some changes to how editor styles are parsed and prefixed.
    The issue could be either a “bad” character in the CSS and WP rejects it, or its loading but WP is no longer prefixing it.

  • Hi David,

    thank you for your reply.
    The actual site I’m working on is local, but I’ll send you the link to a test installation where you can see the whole thing. I have the same css running on the test installation

    It used to work very well with the php-snippet, but not anymore.
    My editor view now looks like this: https://prnt.sc/5Nq6x6DiPHg2

    I have defined the paddings of the containers via style.css, and also the buttons. But all this is no longer displayed in the editor.

  • If you open the editor, and Right Click > Inspect the editor window to open the Browser developers tools.
    In the Console tab are there any Errors or Warnings ?

  • OMG, it could be so easy! Yes, there was that error message:
    https://prnt.sc/jiRBpCsxhctM

    I fixed the error, the editor is now completely fine again πŸ™‚

    When I open the console now, this message still appears: https://prnt.sc/Rc8sOXlW7AWu

    but the display in the editor is saved πŸ™‚πŸ™‚πŸ™‚

    Thank you very much !!!

  • The other warning can be safely ignored.
    Glad to hear that you got it working

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