Css modifications categories/subcategories
-
Is there a way to make css changes to main categories (on my blog “ma santé, mon budget …”) apply to subcategories? Right now even though the parent is modified, the children keeps the default theme.
The blog I need help with is: (visible only to logged in users)
-
Guau. Not an easy question at all! But, let’s try. If I’m right, your CSS custom code additions have this scheme:
.archive.category.category-budget.category-30207 .page-title{color:#2a672d !important}So you use class selectors in BODY tag. But this BODY tag classes do not refer to the taxonomy of your articles, but to the request made to the server. I mean, if your visitor clicks to see Budget category, you’ll have “archive category category-budget category-30207” but if he/she clicks so see the subcategory Epargner, you’ll have “archive category category-epargner category-161209” (no references to the fact this is a subclass of budget) on class attributes in body tag.
On the other hand, you have articles, and in this case, generated tag includes information about categories to what this article belongs. For instance, you have the following classes in your first article in https://solucreap.wordpress.com/category/budget/:
<article id="post-130" class="post-130 post type-post status-publish format-standard hentry category-aidesbudget category-budget category-credit category-epargner category-impots category-risques category-suivibudget">That means you could automatize -in the way I understand you want- rules to be applied inside the article –basically the bordered area- but not outside –for instance site-footer or navigation.
Ok. So that means you could use selectors to apply rules to article frame borders, background and text using “.category-budget.hentry” instead of “.archive.category.category-budget”. Rules should be like these (These are the examples for budget category and subcategories). And this should affect your articles.
.category-budget.hentry {border-bottom:4px solid #1b4c1d !important;border-left:2px solid #1b4c1d !important;border-top:4px solid #1b4c1d !important;border-right:10px solid #1b4c1d !important;color:#2a672d !important;background-color:#dbffdb !important} .category-budget.hentry .entry-title a{color:#1b4c1d !important}What about .main-navigation, .site-footer or .page-title? If you want your navigation bar or footer changes with each menu option, I do not see other option apart from create specific rules for each screen :(
J’espère que ça pourra t’aider au moins un tout petit peu. Salut.
-
(J’écris en anglais au cas où quelqu’un ait besoin de ce post)
Thank you for your answer! I definitely see what you mean and here’s the reason why I didn’t do each subcategory one by one : This blog is actually a commission and will be used by people who have no knowledge of wordpress or coding. So the problem here is, if they want to create a subcategory, it’s going to look bad, and I will not be around to fix it.
I was just hoping there would be some kind of selector for subcategories only (by the way, i’m fine with articles ending up with the “general” theme rather than the categories’).
-
Hi @solucreap, I’ve looked at this also and don’t see a way to specifically style subcategory pages as a group. It would require changes and additions in the theme PHP script files, and we cannot edit those files at WordPress.com.
-
Thank you for your answer thesacredpath, I guess I will manually style pages then and talk about it with my boss.
Thanks again to both of you, i’m closing the topic :)
-
- The topic ‘Css modifications categories/subcategories’ is closed to new replies.