How to Add/Show Category Images in WordPress


If you are customizing or designing your theme, you can link images with categories in the post. All you have to add some simple PHP code to your WordPress theme with some basic HTML knowledge and specific images for categories.
First of all, you must know about the get_the_category tag. You can read detail about what this tag is in the WordPress documentation here.

Here is the code which is a good hack for adding images to the categories.

<h3>Posted in:</h3>
<?php foreach((get_the_category()) as $cat)
    $catname =$cat->category_nicename;
    echo "";
    echo "<img src"/wp-content/cat-icons/";
    echo $catname;
    echo ".png" alt="$catname category image" border="0" />\n";
?><br />

WordPress Plugins for Category Images

Category Icons Lite

The Category Icons plugin is written by Brahim Machkouri, and the author has made a website dedicated to this plugin ) where you can find many more information like full documentation, FAQ’s and a ‘Troubles’ section where you can ask your questions regarding the plugin.

It’ll work with a lot of themes. Just try. If you have an issue, make sure your template has the post title preceded by the permalink and its title :

<a href="<?php the_permalink() ?>"... title="<?php the_title(); ?>">
<?php the_title(); ?>


<a title="<?php the_title(); ?>"... href="<?php the_permalink() ?>">
<?php the_title(); ?>

How to use it :

  1. Deactivate the Category Icons Lite plugin if it was previously installed and activated.
  2. Upload this plugin or install it via WordPress
  3. Activate this plugin through the ‘Plugins’ menu.


Category Icons

The No. 1 plugin to assign icons to categories easily.

More Info & Download

Category Image(s)

Display an image for each category associated with a post.

This plugin provides the templates tag c2c_the_category_image() which basically reproduces and extends the functionality of WordPress’s core functionthe_category() to add the ability to display a category image instead of the category name in the link to the category archive. With its $image_extensions argument defaulted to "", the plugin could be a drop-in replacement forthe_category(). As is done in the_category(), the image or text for each category is also a link back to that category’s archive.

More Info & Download

Leave a Reply

Your email address will not be published. Required fields are marked *

Sign Up for Our Newsletters

Get notified of the best deals on our WordPress themes.

You May Also Like