Support » Themes and Templates » Category Image

  • Hi, everyone. I’m interested in having individual category icons that align similar to this site:

    As I’d like to have a different icon for each category, I stumbled upon this page:

    Which has the following code:

    <?php foreach((get_the_category()) as $cat)
    { echo ‘<img src=”’ . $cat->cat_ID . ‘.jpg”
    alt=”‘ . $cat->cat_name . ‘” />’; } ?>

    It works pretty well, but it displays every category icon that you’ve assigned to the post.

    I have two questions:

    01 – Is this the best way to go about what I’m trying to achieve?

    02 – Is there a code variation that will simply show the first category image or a category image of my choosing?

    Thanks in advance for any help you can provide.

  • The topic ‘Category Image’ is closed to new replies.