Cover block content not overlaying
-
Any content that I insert in the cover block is rendered below the background image instead of overlaid. I am not sure what I am doing wrong.
The page I need help with: [log in to see the link]
-
Looking at the browser development tool it seems that the cover block style in wp-includes is not loaded for some reason.
Hi @lorensimon! I have noticed you are working with a Twenty Twenty-Three child theme.
Could you activate the parent theme for a moment and-retest this? I wonder if this could be an issue with the customization you made.
Thank you!
Hi Alvaro, I tried and it does not change. I also eliminated all custom CSS but still no difference. The only way it works is if I start from a fresh WordPress installation with the standard theme. But that means that I would need to rebuild the site from scratch and potentially at some point could bump into the same issue. Not having a great time with the full site editor……
I tried and it does not change. I also eliminated all custom CSS but still no difference. The only way it works is if I start from a fresh WordPress installation with the standard theme.
Hi @lorensimon from what you have described it seems there is something on this particular site that is causing this issue. In this case, I would suggest troubleshooting the site while it’s on the parent theme.
Please attempt to disable all plugins including Gutenberg. If the problem goes away, enable them one by one to identify the source of your troubles.
If you are worried about how your site will look when you deactivate the plugin, you can use the Health Check plugin to troubleshoot your site Health CheckDisabling all plugins with the current theme did not solve the issue. Using the parent theme removes all the custom template parts, so there is nothing to test because the entire front page functionality is gone. The other thing to notice is that when I am in site editing mode, the cover functionality appears correct. But when I am browsing the page, there seems to be functionality that enqueues the stylesheets for the blocks being used, and the cover block is not being detected as used. Quite frustrating.
It sounds like you took all the good troubleshooting steps… very frustrating indeed.
Ok, so I tried to replicate the layout on a test site and it seems to work fine:
The markup for the above (copied from the editor) would be this:
<!-- wp:cover {"url":"https://gutenbergcore.mystagingwebsite.com/wp-content/uploads/2022/10/6e261ba9-67ef-3f60-b56c-3b06a3480d0b.jpg","id":6040,"dimRatio":50} --> <div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-6040" alt="" src="https://gutenbergcore.mystagingwebsite.com/wp-content/uploads/2022/10/6e261ba9-67ef-3f60-b56c-3b06a3480d0b.jpg" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:columns --> <div class="wp-block-columns"><!-- wp:column --> <div class="wp-block-column"><!-- wp:paragraph --> <p></p> <!-- /wp:paragraph --></div> <!-- /wp:column --> <!-- wp:column --> <div class="wp-block-column"><!-- wp:heading {"textAlign":"center","backgroundColor":"cyan-bluish-gray"} --> <h2 class="wp-block-heading has-text-align-center has-cyan-bluish-gray-background-color has-background">Text to the Right</h2> <!-- /wp:heading --></div> <!-- /wp:column --></div> <!-- /wp:columns --></div></div> <!-- /wp:cover -->I then copied the public markup from your site, pasted on my test site using a Custom HTML block and it indeed looks broken:
Here’s the really weird part, if I combine the two cover blocks (the one I copied from your site and the one I re-created manually on mine), your block looks ok!!
I see three things we could try:
- Remove your cover block and add it from scratch (you have probably tried this already but it is worth a shot).
- If the problem persists, try copy pasting the code I shared above to see it that one looks good on your site.
- If MY cover block also looks broken on your site, could you please share the full HTML code for YOUR cover block (you can copy the entire block via the editor and use a “Code Block” to paste it here).
I’m really curious, let’s see if we can figure this one out together!
Hi Alvaro, first of all thanks for spending time helping troubleshooting.
Second, the issue is not with the HTML code, but with the CSS / style. If you use developer tools in your browser, as well as a fresh test site I built, you will see under the sources section that there is a folder wp-includes/blocks/cover, which is missing from my problem site. I am not a developer, but looking at the response of my test site, as well as your test site, there is a statement that links the cover stylesheet from wp-includes, which is missing from my problem site. I have not yet been able to locate what triggers it, but it seems to me that the WordPress functionality looks for the blocks that are used to figure out what blocks styles needs to be linked. Maybe because my cover block is in a custom template parts of or for some other reason that I don’t know WordPress does not see that the cover block is being used, so it does not bring the corresponding block style.
<link rel='stylesheet' id='wp-block-cover-css' ......To prove my reasoning, I copied the content of the file style-rtl.css under /wp-includes/blocks/cover and pasted into the “additional block CSS” in the site editor under the cover block, and the functionality is now working.
This is a workaround as I want to use the standard blocks styles. I still want to figure out what from my problem site is telling WordPress to not link the standard cover block stylesheet while, for instance, the navigation block stylesheet is linked correctly.
Thank you for the additional details and for narrowing down the issue. It seems clear that something is preventing that stylesheet from loading.
Could you please confirm what version of WordPress you are using? Also, if you are using the Gutenberg plugin, what version is it?
Thank you @lorensimon!
Hi Alvaro,
I am using version 6.2.2 with no Gutenberg plugin. I did some further troubleshooting but I did not yet found the root cause.
I see, thank you for confirming your WP and Gutenberg versions.
Looking more closely at the site, it appears the fonts are not loading properly, and I wonder if there is a syntax error in the theme’s theme.json file. While this likely is not what’s causing the issue with the Cover block, it would be good to check if there’s an error and fix it if possible.
To check if there is an error, you can navigate to the Theme File Editor in the admin and then select the theme.json file in your current theme. If there are any errors, they will appear with a red X icon. Often, they are the result of an extra comma.
Please confirm that there are no errors or that they have been fixed, and we can continue diagnosing the Cover block issue. Thanks!
Hi Alvaro, thanks for keeping looking into this with me. I checked the theme.json and there are no errors, but I had already tried to replace my theme.json file with the standard theme one and it had not solved the problem. I am also trying to share a screenshot (I am not able to upload images to hopefully you can see the link) where you can see that the cover block is correctly rendered in the editor. In my troubleshooting I understood that the way editor pulls in the css code is different from the way the frontend does, which explains why one looks good and the other does not.
-
This reply was modified 2 years, 10 months ago by
lorensimon.
I am not able to upload images to hopefully you can see the link
It looks like the link did not come through. Could you please try sharing it again? You can also upload it YouTube, Vimeo, Loom, and Imgur and embed it using the embed block.
It should be easy to just put a link to a page of my website where I put the image….hopefully it works.
Hi Alvaro,
with some deeper troubleshooting I was able to locate the root cause of the problem. The blocks.php program looks for style.css or style.min.css in dev.collegegolfdrive.com/wp-includes/blocks/cover. In that folder only the style-rtl.css and style-rtl.min.css existed.
Once I copied these files from another installation, the cover block appeared fine.
I don’t know if these files were always missing or what caused them to disappear.
I will for now mark this as resolved and will continue to work on the website. If the problem appears again I will open another thread.
Thank you for your help in troubleshooting.
The topic ‘Cover block content not overlaying’ is closed to new replies.




