Archived topic
Apply (easily) the same CSS to 20 different archives-category pages
3 replies · Started by Jean-Pierre on September 30, 2018
Hello,
I discovered GeneratePress a month ago, after trying several themes (divi, extra, newspaper, genesis)… Honestly, I am thrilled with the theme : simple, flexible, low price, fast… If perfection exists, this theme is close to it for me ! Thank you for inventing it !
Here is my question.
I would like to style each archive-category page (color title, color posts, color background) with the same color than its parent-category. There are only 6 parent-categories in my blog, but there are more than 160 sub-categories, sub-sub-categories and sub-sub-sub-categories !
Is there a way to just apply, all at once, the same style to each parent and its 20/25 sub-categories ? (and avoid to style each of the 160 subcategories one by one in CSS) ?
Thanks for your help !
Hi there,
found this snippet a little while ago that grabs ancestor classes and straps them into the body tag:
https://gist.github.com/hearvox/138586b3741b012c2e9378421f4fb209
It works ! Marvellous ! I Just had to "copy-paste" the code PHP in the link you provided (I do not understand PHP at all!!) and boom ! Each page-category has now the same class name than its parent !
You are really great !
Thank you so much !
That's awesome - thank the author of the Gist :) it also adds categories to any children of posts and pages