WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 0 down vote accepted

the basic way is to

    { 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 -

    { color: pink; }

    { color: green; }
share|improve this answer

Your Answer


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.