Archived topic
CSS only on category pages
3 replies · Started by Michael on August 15, 2021
Long story short (apt)
I have a large quote block at the start of several posts from a few categories. The excerpt is grabbing that which is fine. However in the category pages, the look wasn't good. GP seemed to ignore the excerpt length in the customiser and showed the full quote. I found some useful CSS code which nicely truncated this down to 6 lines, looked great. However the same CSS is also truncating the quote in the post itself.
Question therefore is how do I get this CSS to work only on category pages. I've tried adding archive category to the class, but that didn't register. The only difference I see in the CSS is that the category entries have post-id's as part of their CSS.
#main .wp-block-quote p{display:-webkit-box;overflow:hidden;-webkit-line-clamp:6;-webkit-box-orient:vertical;overflow:hidden}
is what I'm using to truncate the long text on the category pages.
Hi there,
Category archives have unique tags in the <body>.
Let's take this page for example:
https://gpsites.co/marketer/category/uncategorized/
The unique class is here:
https://www.screencast.com/t/rTIajhd5b6Xr
So if we want to change the body background color of that page, the CSS would be:
body.category-uncategorized {
background-color: #000;
}
Thanks for that explanation Leo.
No problem :)