That depends upon how you are generating the category links.
I’m using the_category tag within the loop. Is there any other way?
There’s not much written about the_category tag. Seems like a no brainer to be able to style multiple category links in a post but no one seems to be able to do it.
For use in The Loop to do what you want with it:
<?php
foreach((get_the_category()) as $category) {
echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> ';
}
?>
Thanks, but this still doesn’t generate class id’s for each category in the post.
What HTML do you want generated for these two categories two categories on each of these posts.:
post 1
category xyz
category abc
post 2
category xyz
category mlv
Something along these lines:
<ul class="post-categories">
<li class="xyz"><a href="http://mysite.com/blog/category/xyz/" title="View all posts in xyz" rel="category tag">xyz</a></li>
<li class="abc"><a href="http://mysite.com/blog/category/abc/" title="View all posts in abc" rel="category tag">abc</a></li>
</ul>
<ul class="post-categories">
<li class="xyz"><a href="http://mysite.com/blog/category/xyz/" title="View all posts in xyz" rel="category tag">xyz</a></li>
<li class="mlv"><a href="http://mysite.com/blog/category/mlv/" title="View all posts in mlv" rel="category tag">mlv</a></li>
</ul>
<ul class="post-categories">
<?php
foreach((get_the_category()) as $category) {
echo '<li class="'.$category->slug . '"><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name . '</a></li>';
}
?>
</ul>
Related:
CSS
Stepping Into Template Tags
Stepping Into Templates
Template Hierarchy
Brilliant. Worked like a charm. Thanks for directing me to those links too. Can’t emphasize enough how much stress you relieved!