Created
July 9, 2015 20:36
-
-
Save braginteractive/b022f986a8c1a739f7b6 to your computer and use it in GitHub Desktop.
Add a class to each tag in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$tags = get_the_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; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment