• Resolved Sinopa

    (@sinopa)


    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? ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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.

    Thread Starter Sinopa

    (@sinopa)

    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";
    	}
    ?>

    much butter dude ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘category image’ is closed to new replies.