-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add Template Specific CSS instead of only global in the Additional CSS section #50160
Comments
Aint this already possible using is_page_template() within wp_enqueue_scripts action while registering the scripts? |
Of course, what you're saying is possible, with PHP and for advanced users. This is more like a convenience feature. This adds inline code to the page, which is kind of a bummer. Would be nice if it created a minimized CSS file. Actually, that would be amazing! |
On a test site with a default theme setup. I get this in the body tag.
Similarly, there are numerous automatic classes added to pretty much everywhere. Making things specific to a page or a template, or whatever is easily done with these class selectors. So from a functionality standpoint, this type of selection is already easily done. What you are proposing here is for there to be a second CSS selection when the template or page, or something like that, which inserts that CSS only onto that page or whatever. This means adding queries to retrieve the metadata and display it, as well as the UI necessary for entering that CSS. Now, while this could be done, it's not a Gutenberg issue as such. It's a more generalized WordPress issue to support having per page/template CSS. Additional PHP based functionality would be required to load and pull that data to be inserted into the page. Personally, I don't think it's worth it when this CSS is all inline in the first place. However, regardless of that, it would be an issue that you probably should discuss on the core trac first, as it requires adding a new system to WordPress itself, rather than just Gutenberg for the UI. |
|
What problem does this address?
The blocks are very basic. We need more control, especially for responsive designs, not to mention animations...
If you're adding all that CSS globally, you're bloating the site.
The default theme has 11 templates.
Each template and template part heeds its own specific set of CSS rules.
What is your proposed solution?
My suggestion is to add a tab for Local CSS, so that you may choose, whether your CSS should be loaded globally, or only for that specific template or template part.
While on the topic
Would like to see something similar for JavaScript as well. Would require a lot more options, though...
Like: defer / async, load in head, body footer, add ID, etc.
Is that a possibility? Should I create another suggestion?
The text was updated successfully, but these errors were encountered: