• I’ve applied a style around my “get_category” as below;

    <span class="<?php $category = get_the_category(); echo $category[0]->category_nicename; ?>-highlight">
    <?php the_category(',') ?></span>

    The problem is this applies the same style to all the categories listed. Can I do something like this…

    <span class="<?php $category = get_the_category(); echo $category[0]->category_nicename; ?>-highlight">
    <?php the_category('</span>, <span class="<?php $category = get_the_category(); echo $category[0]->category_nicename; ?>-highlight">') ?></span>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Just iterate through each category

    <?php
    foreach((get_the_category()) as $category) {
        echo '<p>'.$category->category_nicename . '</p>';
    }
    ?>

    Thread Starter ibeats

    (@ibeats)

    Close, but not quite, though I guess It’s me that’s not doing the right thing…

    Take a look at the bottom here; https://www.ibeats.co.uk/ (4,6,7 in Other News) show two categories but are only taking the styling of the first ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Styling get_category… Splitting it…’ is closed to new replies.