views:

32

answers:

2

How do I get the_tags() to output each tag so that it comes assigned with a unique class selector? So for example: the_tags() currently outputs something like this:

<a href="http://myblog.com/tag/kittens" rel="tag">kittens</a>

However, I'd like to output something like this:

<a href="http://myblog.com/tag/kittens" rel="tag" class="tag-kittens">kittens</a>

Is it possible to do this? If so, how? Thanks!

A: 

Use get_the_tags instead, do a for loop and create your own markup.

GmonC
A: 

It worked, thank you! This is what I did:

<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo '<a href="';echo bloginfo(url);
echo '/?tag=' . $tag->slug . '" class="' . $tag->slug . '">' . $tag->name . '</a>';
}
}
?>
Marc P
You can mark my answer as accepted or yours so other people would benefit when searching for this same problem. You can read how SO works in FAQ. http://stackoverflow.com/faq
GmonC