-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hybrid themes: Block CSS is missing when using do_blocks() #40018
Comments
WP 5.9.3 Problem still persist... |
Same problem here. The CSS related to the blocks is not included. Would there be a way to just basically include all CSS of the possible blocks (and thus fix our issue?) |
The solution right now is to:
I am not sure that is the long term solution that we want.... |
This seems like quite a big deal to me. Trying to merge a site with custom post types and custom fields into FSE is going to be very problematic until this is resolved? |
The only thing that changes is the position so I don't think it is necessarily more messy. |
@carolinan 👋 Hi! I have a related problem to this but a bit different context. I'm trying to make an Advanced Custom Field PHP block template behave like a FSE HTML template (basically I want to paste Gutenberg output into the template and have it render correctly.) I've attached a Gist of my code which uses This actually works great on the frontend of the site, but when in the Gutenberg editor, the styles do not get applied, probably for the reason discussed in this thread where the CSS does not get applied. It should be possible to make it work inside Gutenberg if I can just access the generated CSS when using Example of the problem: Backend (preview does not look right)Frontend (everything works) |
Is this still the recommended workaround? I'm trying this exact solution and the block CSS still isn't being enqueued. |
I am not aware of any changes that would affect it. |
I made a quick test with a classic theme, I added the code above and the two template parts, and the styles are applied. |
Weird. Maybe it's the theme I'm using or something. |
A similar issue and solution regarding the failure of CSS to load when using the
Here's a template that successfully loads the block CSS:
|
This continues to persist, but it's exceptionally odd. I'm attempting to exclusively use FSE so that my client can manage her blog layouts in the site editor. Let's say each blog post has a "card". That "card" should be used in the query loop as well as anywhere else the post gets displayed. FSE allows me to have a singular template part with a synced pattern inside it to display everywhere. This MOSTLY works perfectly until I have to interact with plugins. I'm currently trying to use: block_template_part('block-post-single'); to display the template part inside a plugin's filter, and while the actual CONTENT is perfect, and the inline styles ARE coming over, the formatting of the wp-container-core-group-is-layout-ID does not work because weirdly, the ID in wp-container-core-group-is-layout-ID actually changes when the page gets rendered. So at the outset, let's say that ID is 104, when the page rendering is complete, it ends up being 82 (as an example) and therefore, the CSS that does output for wp-container-core-group-is-layout-104 is irrelevant. And even worse, the styling for layout 82 (which obviously would have been completely different) now applies to what should be ID 104. (I hope this spaghetti is making sense). If anyone has any thoughts on a workaround, I'd very much appreciate it. |
Description
If you use do_blocks() to render a block, the CSS normally placed in a style tag for the wp-container-uniqueID inline in the document is missing. Such as the flex, margins, widths and alignments.
Step-by-step reproduction instructions
Use do_blocks() (in a front facing template file) to render a block with a layout setting like a group or template part.
Confirm that the CSS is missing on the front.
In empty theme, create file called search.php (Place it in the root directory, not templates)
Add this sample code:
Go to the front of the test site and do a search.
See that the layout is left aligned, not wide with a centered heading.
View the source and see that the CSS styles for alignments in
wp-container-uniqueID
is not printed.Copy paste the same block markup to a post or page and compare the two layouts and the CSS.
The post has the following CSS applied:
Screenshots, screen recording, code snippet
No response
Environment info
WordPress 5.9.3 RC1 nightly
With and without Gutenberg trunk, Gutenberg 12.9.0.
WordPress beta tester plugin
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
No
The text was updated successfully, but these errors were encountered: