When calls theme's style.css file with add_editor_style inside gutenberg, background images are not loading properly.

Lets say:

#intro {
    background: url(assets/main.png) ;

Its working properly on front-end like:


But when in gutenberg, WordPress tries to load:


Am i missing something?

  • 1
    Is there a reason you do not want to set the full relative path in style.css? Have you tried #intro { background: url('/wp-content/themes/mytheme/assets/main.png') ;}
    – Anthony D
    Jan 9, 2020 at 14:47
  • It can be in subfolder installation Jan 10, 2020 at 15:06

1 Answer 1


You can load the css via PHP instead ,

add_action('wpmm_head', 'wpmm_custom_css');

    function wpmm_custom_css(){
     echo '<style>
  • You can't always know all images tbh. This is a problem that needs automatic fix Jan 13, 2020 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.