Different style for different cat headings on homepage
-
Hi folks
I’m trying to colour the background of the excerpt titles on my home page according to the category they are in. (I’ve tried to search for this, but I’m not even sure what to call it so I’m hoping someone can help me.)
I want the headings on index.php to have a different background colour according to their category, to fit in with the colour coding on the rest of the site. Here is an example of what I’d like to do:
Here is my current code:`
<div class=”titlehousekeeping”><span class=”cat_title”><?php the_category(‘, ‘); ?> »</span><span class=”title”>” rel=”bookmark”><?php the_title(); ?>
</span>
</div>
`
I can’t just put<span class="titleculture">Culture >> Lorem Ipsum </h3>, <span class="titlebusiness">Business</h3>
in a list in the excerpt query, as there may be more posts with culture than business, and I want it to be the most recent posts rather than one from each category (I have 7 categories).
I’m pretty sweet with css but I’m very much a newbie to php, so I’m not sure how to call a different css style for the title according to the category it’s in.
What I hoped, was perhaps there is some way to call the word into the php file Like:
<div class="title<?php get_cat_name(''); ?>">
to get<div class="titleculture">
instead of<div class="titlehousekeeping">
.But that doesn’t work.
I hope I’ve been clear enough, any help is really appreciated!
Thanks
Charlette
- The topic ‘Different style for different cat headings on homepage’ is closed to new replies.