Is there a way to have the styles on a page appear differently for certain categories, when viewing a page that is only of that category?
|
Hi @GSto: @EAMann has a great answer if you want different layouts for different categories. OTOH if you only want to change the CSS to, for example, have a different background color for each category then you'll find that most themes will include the category slug as a CSS class on the For example the TwentyTen theme does exactly that; for the following URL: Here's what the
Knowing the above you could add the following styles to your theme's
All you really need to do do figure out if your theme does this or not is to view source on the category pages of interest and search for your category slug. Use a Child ThemeOf course you probably don't want to modify your theme's
Note that not all themes support child themes, Thesis being one notable example. In the case of those themes you'll have to research more into how they are extended. |
|||
|
If you want, you can have a different template for each category with its own set of style definitions. Then you can style the page differently for certain categories, but only when viewing a page that is only of that category. Just use these in your theme:
|
|||
|
|
|
What Eric said. But if you only want to change the style, and not the markup, there's an easier way. As long as your theme includes the body_class() call in the opening body tag, WP will add all sorts of useful CSS hooks to your page. The default markup will add the follwing classes to the body element on a category archive:
which you can style as you like. A lot of theme frameworks will add even more useful hooks to your body class, although some of them I can't possibly see the real-world use cases for. |
|||
|
|