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?

  • 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 at 14:47
  • It can be in subfolder installation – Ünsal Korkmaz Jan 10 at 15:06

You can load the css via PHP instead ,

add_action('wpmm_head', 'wpmm_custom_css');

    function wpmm_custom_css(){
     echo '<style>
| improve this answer | |
  • You can't always know all images tbh. This is a problem that needs automatic fix – Ünsal Korkmaz Jan 13 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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