• Resolved marg0

    (@marg0)


    Hello,

    I’m brand new to WordPress, so forgive me if this question is immature.

    I have a navigation that I want to change style based on which category is active (which category the user is in at the time.) An Active state, basically.

    I have a class in my css for “selected”, so an active link would be like this:
    <li class="his"><a class="selected" href="https://myURL.com/category/his/">His</a></li>
    and an unactive link would look like this:
    <li class="hers"><a href="https://myURL.com/category/hers/">Hers</a></li>

    My problem is, my navigation is in my header.php template, so I need the active category to ‘auto select’. I tried adding <?php } elseif (is_category('his')) { ?> in a couple places, but that doesn’t seem to be working.

    Any ideas on how I can make this work?

  • The topic ‘Styling a Link based on the active Category’ is closed to new replies.