• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WPArena

WPArena

WPArena is a premium online resource site of WordPress and is focused on providing excellent WordPress Tutorials, Guides, Tips, and Collections.

  • News
    • Opinion
  • Tutorials
  • Reviews
    • Themes
    • Plugins
  • Comparisons
  • Collections
    • Education Themes
    • Genesis Child Themes
    • Best Responsive Themes
    • Medical WordPress Themes
    • Finance & Business Themes
    • Crowdfunding Themes
  • Resources
    • Inspiration
  • Services
WPArena » Tutorials
Tutorials

How to Add/Show Category Images in WordPress

Avatar of Noor Mustafa Raza Noor Mustafa Raza Updated: April 24, 2020

FacebookTweetPinLinkedInEmailPrint

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(); ?>

or

<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-icon-plugin

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

This post was orginally published on: July 3, 2011 and was updated on: April 24, 2020.
FacebookTweetPinLinkedInEmailPrint

Related Stories

  • How to Create Special Text Areas with CSS in WordPress Post

  • How to Convert Blog Visitors into Subscribers & Readers

    How to Convert Blog Visitors into Subscribers & Readers

  • How To Add BlogRush To A WordPress Blog

    How To Add BlogRush To A WordPress Blog

Avatar of Noor Mustafa Raza

Noor Mustafa Raza

Ex-Editor in chief

I am a WordPress Developer and Designer, author @WPArena. I am providing Free WordPress consultation and can help you to install WordPress in a secure way to small businesses and bloggers.

Reader Interactions

Share Your Thoughts Cancel reply

Before submitting your comment, we kindly ask that you read our comment policy. Your email address will remain confidential and will not be published or shared anywhere. If you subscribe, you will receive notifications regarding new comments.

Primary Sidebar

Improving WordPress security

How to Take a ‘Block Editor’ Approach to Development

How to Managing Your WordPress Multi Sites

Recent Topics

  • Official Windows 7 Wallpapers
  • How to secure your WordPress images and content from Theft
  • Top 20 Web Designing Companies in the World
  • WP Rocket Review: Is It the Perfect Solution for WordPress Caching?
  • The Complete WordPress Security Guide 2023 – Step by Step

Footer

Top

  • Services
  • Our Themes
  • Facebook
  • Twitter
  • Linkedin

Reviews

  • Beaver Builder Review
  • Beaver Themer Review
  • WP User Frontend Pro
  • Ninja Forms Review
  • MemberPress Review

More Reviews »

Resources

  • Best WordPress Plugins
  • WordPress Permalinks Structure
  • Email Management System
  • Envato Free Files
  • Advertise
  • Write for us
  • Disclosure
  • Terms
  • Privacy
  • Contact

Copyright © 2023 · All Rights Reserved · WPArena is a Project of TechAbout LLC.
We are not affiliated with Automattic or WordPress.

  • Advertise
  • Write for us
  • Disclosure
  • Terms
  • Privacy
  • Contact
Share this ArticleLike this article? Email it to a friend!

Email sent!