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 want to style a link depending on its ID, for instance, if the category ID is 2, then I want the link to be pink. My theme calls the category like this:

<?php if (in_array('categories', get_option('theme_postinfo2'))) { ?> <?php the_category(', ') ?>

I found a way to style specific categories in lists by adding:

li.cat-item-7 { ... }  /* category ID #7, etc */

to my stylesheet, however, I cannot find a way to do the same thing to links. What type of solutions are available? Please be detailed in your reply as my coding knowledge is limited.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

the basic way is to

 #li.cat-item-7
    { color: red; }

Now, change '7' to the number you want, as many times as you want and 'red' to the color you want for that category like -

 #li.cat-item-2
    { color: pink; }

    #li.cat-item-8
    { color: green; }
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.