.. they should already exist as classes if the theme is using <?php post_class(); ?>
http://codex.wordpress.org/Function_Reference/post_class
It’s possible you might need to describe the section you want each class to have a different background, what I posted above is for the post itself.
Thread Starter
wyndot
(@wyndot)
Thanks for the quick response.
I don’t actually want the whole post to have a different background.
I’m building a portfolio and each project has some custom taxonomies listed that describe the project. I basically want to add the program icons in the tools category. If each link has its own class I can do that as a bg image. See the following image:
http://www.geoffponnath.com/wp-content/themes/gportfolio/images/example.jpg
heres my code i’m using to list the taxonmies now:
<h3>Skills</h3>
<ul class="taxonomy"><?php the_terms( $post->ID, 'skill', '<li>', '</li><li>','</li>' ); ?></ul>
<h3>Tools</h3>
<ul class="taxonomy"><?php the_terms( $post->ID, 'tool', '<li>', '</li><li>','</li>' ); ?></ul>
I do have an answer for this, writing it up right now
Do you want it only to list the categories that the current post is in right? with css that befits it right?
Thread Starter
wyndot
(@wyndot)
Thanks!
Yep, just for that current post, with a unique class for each category (or taxonomy) name.
yeah i’m writing something up that uses
$categories = &get_term_by(‘id’, $post->ID, ‘category’);
that will get all the categories of a post and then write it out for you in the style you want, need a few minutes to finish it ;/
unless of course you want to do it with that lead in on how to π
[removed bad link, see post below]
Here’s a widget for ya.
basically what it does it will get the categories for the post, if none exist display no categories found, otherwise it will format it out with
echo '<li class="cat-'.$cat->slug.'">'.$cat->name.'</li>'."\r\n";
Which cat-<slugname> of the category so you can use that to do a background image then margin-left: it the pixel amount of the image
It uses $cats = get_the_category( $post->ID ); so that it only grabs the categories of the current post for ya.
Probably need to add an if (is_single()) { wrapper on it so that it doesn’t display on the home page or pages archives etc.. and only on single pages.
Thread Starter
wyndot
(@wyndot)
Thanks, that sounds great, I’ll give it a try!
http://wp.pastebin.com/Q2vVmdf2
Here, this is all fixed up, including clickable links