I want to sometimes have some custom CSS applied to only a particular page or post. I’m relatively new to ACF and not too sure how to implement this. I read another post about CSS in the admin end, but I’m after something for a one off page or post as required.
I don’t think there’s any magic way to do this using the built-in tools or functions (I could be wrong), but this is what I’ve been thinking:
- have an ACF for CSS data
- have an ACF checkbox to determine if the CSS should be applied or not
- in the page template check for both and if they exist and the cb is active, apply said CSS
But I’m not exactly sure how to do it. So first off, is what I want to do above the right way to go about it?
I COULD just load something like the CSS Plus plugin, but my idea is to get away from forever installing new plugins. Would I be better off just using the plugin? It does format nicely within the post admin area (although I’ve just realised it doesn’t appear on custom post types, so ACF may be the only way to go).
The theme will be my own, ie it’s a work in progress (based on _s).
Custom CSS for one page (using the above method) feels like it’s doable, but what about having CSS for a set of posts? The CSS can be lengthy, and generally I wouldn’t want it loaded for all pages/posts, how could I have it apply to a set of posts/pages/custom types without overloading the database—by that I mean to not repeat the same CSS throughout the database).
ie Could I somehow attach the CSS to a taxonomy? Probably a tag more-so than a category, but either.
Any thoughts would be appreciated.