Support » Themes and Templates » [Resolved] Styling category links differently

[Resolved] Styling category links differently

  • Hi everyone,

    I’m trying to figure out how to style the category links with different colours. I’m using the post_class function to generate dynamic classes – which works fine when only one category is assigned to a post – but when two or more categories are assigned the links inherit the classes and get the same styling.

    How can i separate the classes so that each category link has a unique css style?

    Here’s a link to a screenshot which hopefully illustrates what the heck I’m going on about 🙂

    Any help is greatly appreciated!


Viewing 2 replies - 1 through 2 (of 2 total)
  • For anyone interested I worked out a solution by using the “CSS atrribute selector” to target each tag-links’ title attribute – wordpress automatically adds a title of:

    title=”View all posts in (category name)”.

    So I targeted each category with a css selector like this one, to target all links with a title attribute containing the word “Design”:



    If anybody has a better solution – or workaround – feel free to add it in here!


    I was trying to do the same thing and ended up using this code in a “Recent Posts” widget.

    <a class="<?php $category = get_the_category(); echo $category[0]->cat_name; ?>" href=...

    I wrote up a little more on it on my blog:
    Style Links with CSS by Category – WordPress

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Styling category links differently’ is closed to new replies.