• Resolved moderno

    (@moderno)


    Hi, im looking for some help to be able to list categories with the list categories tag, but instead of displaying the titles of the categories, i would like to display an image, associated to that category. I dont know how to proceed with this, and i hope someone with more knowledge on the subject could help me resolve this. Thanks !

Viewing 5 replies - 1 through 5 (of 5 total)
  • The Category Images plugin might be helpful, if not for the plugin itself, then at least to get an understanding of the code needed.

    That plugin is over two years old!

    Still works for me on 2.3.1 ??

    Thread Starter moderno

    (@moderno)

    yeah, ive already tried that plugin, but it only works within the loop, so its not going to help me ??

    Thread Starter moderno

    (@moderno)

    I found a way to do this without using any plugin. I just used This Article

    mixed with this This Article

    to get some code like this one:

    <?php foreach((get_categories('exclude=1,4,6,7')) as $cat) {
    
            echo '<a href="https://example.com' . $cat->category_nicename . '"><img src="https://example' . $cat->category_nicename . '.png" width="178" height="28" alt="' . $cat->cat_name . '" /></a> ';
    
          } ?>

    So with this code, we can display a picture for the category that links to its category page, instead of showing the category’s title and the typical link.

    Hope it helps!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘List Categories with an image instead of category title!’ is closed to new replies.