• 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 Author

    Content

    Listed in: Cat 1 (<- this would be red), Cat 2 (<- this would be green)

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • If your theme uses the body_class() function, you can do this using pure CSS.

    Thread Starter salromano

    (@salromano)

    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?

    Thread Starter salromano

    (@salromano)

    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="https://website.com/category/category-1">Category 1</a><a href="https://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.

    Thread Starter salromano

    (@salromano)

    Can anyone help me with the separation?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Category Link Colors’ is closed to new replies.