I need a hack or plugin that will allow me to change the link color of a category displayed in a certain area.
For example, if I have a post:
Title
by AuthorContent
Listed in: Cat 1 (<- this would be red), Cat 2 (<- this would be green)
Any ideas?
I need a hack or plugin that will allow me to change the link color of a category displayed in a certain area.
For example, if I have a post:
Title
by AuthorContent
Listed in: Cat 1 (<- this would be red), Cat 2 (<- this would be green)
Any ideas?
If your theme uses the body_class() function, you can do this using pure CSS.
New things are pretty easy for me to latch on to - what's the body_class() function and how could I use it to accomplish my goal?
I've been looking around. Here's what I've managed to put together from my findings:
<?php $the_cat = get_the_category(); $category_link = get_category_link( $the_cat[0]->cat_ID ); foreach((get_the_category()) as $category) { echo '<a class="'.$category->slug.'" href="'.$category_link.'">'.$category->cat_name.'</a>' ; } ?>
This way, it appears as such:
<a href="http://website.com/category/category-1">Category 1</a><a href="http://website.com/category/category-2">Category 2</a>
Then, you go into your CSS, and add the following:
a.category-1 { color: #333; }
a.category-2 { color: #CCC; }
And so on.
Only problem: I need a way to separate the categories by comma as they display.
Can anyone help me with the separation?
This topic has been closed to new replies.