WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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 May 10 '11 at 8:48
the_tags() only returns the tags this post is attached to, so every tag there is a current tag, no? – Jan Fabry May 10 '11 at 10:21
Thanks, Michael -- that's helped! – John May 10 '11 at 17:24
@JanFabry Should be an answer then. – kaiser Apr 19 '12 at 3:32

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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