Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using <?php wp_tag_cloud( $args ); ?> to create a tag in my sidebar. With the "args" you can style it quite a bit, even the different text size, but it doesn't seem to be possible to apply different colors.

What I did is a plain CSS solution which looks somewhat like this:

#tagcloud ul .tag-link-8 {
color:#666;
}

#tagcloud ul .tag-link-7 {
color:#7EA7C9;
}

#tagcloud ul .tag-link-9 {
color:#6A9EA5;
}

It works okay, but this is a hassle. I have to apply the colors manually and once I have 50 tags or so this will be kind of ridiculous.

I was wondering if there is a way to connect e.g. the text-size to a specific color (like some tagcloud plugins seem to do anyways) (size:8 = red etc.)?

Anybody any ideas?

Thanks a lot in advance!

share|improve this question
    
have you searched the plugins? for example wordpress.org/extend/plugins/search.php?q=tag+cloud+color –  Michael Oct 1 '11 at 11:54
    
@Michael: Yes, but maybe I should have mentioned that I do not want to use a plugin! :) –  japanworm Oct 1 '11 at 12:06
    
disect the plugins and extract the respective code and add it into functions.php of your theme. –  Michael Oct 1 '11 at 12:44

1 Answer 1

up vote 2 down vote accepted

Use a filter for the tag cloud to change the inline size declarations to CSS classes and declare the colors in your style sheet:

.tag-cloud-size-8
{
    color:     #009;
    font-size: .8em;
}
.tag-cloud-size-10
{
    color:     #900;
    font-size: 1em;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.