7

Essentially what I am hoping to replicate is something like the "current-menu-item" class that is applied to WP Menus.

My client is wanting to use Tags as a sub-nav, and I've managed to get the tags for the category output as an unordered list, but now if someone selects the tag "Tag One", I'd like to have that particular tag to highlight as the currently selected Tag.

It would be extra super cool if this could also work with the output generated by "the_tags" attached to the post as well.

I hope this makes sense, and thanks!

Cheers, John

3
  • 5
    it could help if you can post the code of 'the tags for the category output as an unordered list'; general idea: to use if(is_tag('this-tag') echo 'current'; with each element.
    – Michael
    Commented May 10, 2011 at 8:48
  • 3
    the_tags() only returns the tags this post is attached to, so every tag there is a current tag, no?
    – Jan Fabry
    Commented May 10, 2011 at 10:21
  • 2
    @JanFabry Should be an answer then.
    – kaiser
    Commented Apr 19, 2012 at 3:32

1 Answer 1

1

Add something like this to the functions file:

function current_tag($tags) {
    global $wp_query;
    $cid = $wp_query->query_vars['cat'];
    foreach($tags as $tag) {
        // match tagid to $cid
    }
} 
add_filter( 'get_the_tags', 'current_tag');

This won't work by itself, but it will be a good start for getting the right information to the right place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.