Archived topic
css affecting site speed
5 replies · Started by Ewa on November 10, 2021
Hello,
I would like to ask you for an advice. For the moment I use customizer css to change styles on website.( CSS in external file).
I would like to apply some css changes only for posts from specific category. I am wondering how to approach to that. I consider two options:
1. the plugin which enables that: https://wordpress.org/plugins/postpage-specific-custom-css/
2. Adding css field in admin to each post and page via advanced custom fields and then output css code from there in headers of each post / page (here said how to do it: https://www.satollo.net/custom-css-post-advanced-custom-fields-and-header-footer)
Which approach do you think would be better for site speed?
Hi there,
how much CSS are you writing for those category specific posts ?
not much, just to add a border box with shadow and maybe two or three things more like this
You could use a Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/
In the Hook content add your CSS inside style tags:
<style>
Your CSS goes here
</style>
Set the Hook to wp_head
Set the Display Rule Locations to Post Category > Your Category.
I didn't know it's possible. Great. Thats even easier.
Thank you very much
Glad to be of help