The code you have is only going to render one image, do you realise that?
You’re outputting a loop of categories inside the src part of the image..
So you’ll end up with one image that has a path like…
wp-content/themes/YOURTHEME/images/category1-category2-category3-category-4
and so on….
Gimme 5 mins, i’ll write you something… 🙂
EDIT::
Ah, i think i misread slightly, you’re doing this inside the loop for each post…
I’ll see if i can make you something anyway.. 😉
One quick question, do you expect the result to return more then one category or do you want/expect it to return more then one?
I’ll post some code in a moment, we can always adjust it if it’s not quite suited as is… 🙂
Just wanted to test a few different ideas to get it right, here you go…
<?php
$the_cat = get_the_category();
$category_name = $the_cat[0]->cat_name;
$category_description = $the_cat[0]->category_description;
$category_link = get_category_link( $the_cat[0]->cat_ID );
?>
<a href="<?php echo $category_link; ?>" class="category_logo">
<img title="<?php echo $category_description; ?>" src="<?php bloginfo('template_url'); ?>/images/<?php echo $category_name; ?>-tag.png" alt="<?php echo $category_name; ?>" />
</a>
Pretty sure (by looking at your site) you are expecting one category for the result…
Hope that helps… 😉
NOTE: Added a class to the link so you can style it with the CSS to remove the border or anything..
Example:
.category_logo {}
and
.category_logo img {}
You are right about the loop. What I have now is an icon that changes depending on the category the img src returns. There will only be one category assigned to each post, so I need the icon to link to that category. Does that make any since?
Thanks for you help!
Above code will work as is, and will only return the first category…
It will link as required to… 🙂
Any issues, check the path for the image being generated is correct…
I can help further if required.. 😉
Success!! Thanks so much for your help!