zipiz
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Add NAME of top-level category to body classI owe you a beer. Big thanks 🙂
Forum: Themes and Templates
In reply to: Add NAME of top-level category to body classIt’s me again. Can you please modify this code above to
a) remove all classes from the body tag except the ones generated by the code
b) add the same genericClass to all pages that are not in a category (tag pages, author pages, search pages etc.)
I dying to figure it out. Your help is much appreciated.
Forum: Themes and Templates
In reply to: Add NAME of top-level category to body classYou are awesome! It works brilliantly. Thank you so much!
Forum: Themes and Templates
In reply to: Add NAME of top-level category to body classI’m not a coder so all I can do is try to understand the code and copy/paste code others provide.
The first link shows how to add the actual category name in the body, but not the top-level category (parent/root category).
From the second link I tried several code snippets and again, they do not display the parent/root category in the body class.
From the third link I do not quite understand how to make a code snippet off the information there to display the parent/root category in the body class.
is that for category archives and/or single posts?
For single posts and category archives.
what if a single post has several categories?
You make a valid point there. I totally forgot about the case of multi categories. In this case, I simply want to add a generic class in the body tag. I believe this should be doable with a conditional. Something like
if (categories more than 1)
echo ‘genericClass’;