Sinopa
Member
Posted 3 months ago #
I wonder if there is someone here that can help me with a "small" problem :)
I use <?php the_category(',') ?> in my posts, but I would like to use custom images instead of a text link that <?php the_category(',') ?> generates.
If I have a category that's called wordpress, I would like it to display a small wordpress logo for category with a link to that category.
Is this possible? :)
what about this:
<?php
if ( is_category( 'wordpress' ) ) {
$imagePath = 'pathToWorpressImage.png';
}
?>
<img src="<?php echo §imagePath;?>" ...>
you could create a category array with wp_list_categories(); and identify with is_category(); in which category you are and generate a $imagePath you want to display belonging to the different categories.
Sinopa
Member
Posted 3 months ago #
I did like this instead :)
<?php foreach((get_the_category()) as $cat)
{
$catname =$cat->category_nicename;
echo "<img src=\"/wp-content/cat-icons/$catname.png\" title=\"$catname\" border='0' />\n";
}
?>