Title: Show current tag
Last modified: August 30, 2016

---

# Show current tag

 *  Resolved [916VT](https://wordpress.org/support/users/vincent916/)
 * (@vincent916)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/show-current-tag/)
 * Hello,
 * I’m looking for a list of all tags with a special class on the current one.
 * I found this code which works great but I can’t manage to add the special class…
 *     ```
       $tags = get_tags();
       $html = '<div class="post_tags">';
       foreach ( $tags as $tag ) {
       	$tag_link = get_tag_link( $tag->term_id );
   
       	$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
       	$html .= "{$tag->name}</a>";
       }
       $html .= '</div>';
       echo $html;
       ```
   
 * Any help ?
 * Thanks a lot !

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [916VT](https://wordpress.org/support/users/vincent916/)
 * (@vincent916)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/show-current-tag/#post-6189054)
 * I’m trying to figure something like that :
 *     ```
       $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}" . if ( single_tag_title == $tag->name ) { echo 'current'} . "'>";
       ```
   
 * But without success so far…
 * Any help is more than welcome =)
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/show-current-tag/#post-6189055)
 * try using a ternary operator; example:
 *     ```
       $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}" . ( single_tag_title( '', false ) == $tag->name ? " current" : "" ) . "'>";
       ```
   
 *  Thread Starter [916VT](https://wordpress.org/support/users/vincent916/)
 * (@vincent916)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/show-current-tag/#post-6189056)
 * It works perfectly fine !
 * Thanks a lot alchymyth, you’re my hero 🙂
 * Thanks again !

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Show current tag’ is closed to new replies.

## Tags

 * [tag](https://wordpress.org/support/topic-tag/tag/)
 * [tags](https://wordpress.org/support/topic-tag/tags/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [916VT](https://wordpress.org/support/users/vincent916/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/show-current-tag/#post-6189056)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
