Category Images (3 posts)

  1. southerngal
    Posted 12 years ago #

    I would like to associate an image to the category I'm posting about. I know to use <?php the_category_ID() ?> but not sure what to put with it and where it would go. I found this post on the b2 boards, but I tried it and it didn't work.
    Anyone have this accomplished with WP?
    Thanks! :)

  2. Mike Little
    Posted 12 years ago #

    Hi southerngal,
    What you need to do is create a set of images, one for each category you have, and name them with a fixed pattern. For example, catimage1.gif, catimage2.gif, catimage3.gif, etc.
    Then in your main WP loop you can add this to you template:
    <img src="images/catimage<?php echo the_category_ID() ?>.png" alt="Category: <?php the_category() ?>" />
    I've just tried this and it works fine.

  3. southerngal
    Posted 12 years ago #

    Thanks Mike! I will try this tomorrow. :)

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.