WordPress.org

Ready to get started?Download WordPress

Forums

Category Image (1 post)

  1. g0lem
    Member
    Posted 7 years ago #

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

    http://invader-stu.com/holland/

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

    http://codex.wordpress.org/Template_Tags/get_the_category#Show_Category_Images

    Which has the following code:

    <?php foreach((get_the_category()) as $cat)
    { echo '<img src="http://example.com/images/' . $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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags