WordPress: Add Images to Taxonomy Terms

I’ve recently been working on an example plugin/library for adding an image to taxonomy terms (such as categories, post tags, or custom taxonomy terms). The plugin adds an image upload field to the create and edit term forms.


As a developer, you can choose which taxonomy has images and change the field text by using the ‘taxonomy-term-image-taxonomy’ and ‘taxonomy-term-image-labels’ filters respectively.

The plugin’s README file provides a few example usages.

GitHub Repo

17 thoughts on “WordPress: Add Images to Taxonomy Terms

  • Ajith

    works totally fine

  • btheath

    How would I get the image to display on a single product page?

    Example, I have several products, each with a specific manufacturer.

    Manufacturer is an attribute “pa_manufactuer”, with the names of each manufacturer being the term that has the image.

    What I’d like to do is hook into ‘woocommerce_after_add_to_cart_form’ and display the manufacturer image on each single product.

    Could you show me what the snippet should look like?

    add_action( ‘woocommerce_single_product_summary’, ‘my_function_name’);

    function my_function_name() {

    What would go here?


    • Jonathan Daggerhart

      I’m not familiar with that hook (or woocommerce to be honest), but I’m assuming an ad-to-cart form happens on the product page itself. So I think you’d want something like this:

      add_action( ‘woocommerce_single_product_summary’, ‘my_function_name’);
      function my_function_name() {
        $product = get_post();
        $categories = wp_get_object_terms( $product->ID, 'category' );
        foreach ($categories as  $term) {
          if ( $term->term_image ){
              echo wp_get_attachment_image( $term->term_image, 'thumbnail' );

      Not positive if that works, but it should get you a lot closer. The main take away here, is that if you get the category objects, it should have a ‘term_image’ property that is the ID for the image you attached to the category.

  • mrh

    Found an error when adding new category with the image.

    “Notice: Trying to get property of non-object in taxonomy-term-image.php on line 287”

    Any idea? Cheers.

  • Mohammad

    How to use for specific custom post type and custom taxonomy?

    not working:

    function music_term_image_taxonomy( $taxonomy ) {
    return ‘genre’;
    add_filter( ‘taxonomy-term-image-taxonomy’, ‘music_term_image_taxonomy’ );

    • Jonathan Daggerhart

      Hi Mohammad,

      If ‘genre’ is the slug for your taxonomy, that should be working.

      One thing I ran into recently is that someone was registering their hooks after they were including the file taxonomy-term-image.php file. This will cause your hook to be “too-late”, and not get called.

      I’ve just modified the project to delay the instantiation of the class. Try updating on the master branch and let me know if that works.


  • irfan sodawala


    How to assign term image to multiple taxonomies.

    • Jonathan Daggerhart

      Hi Irfan,

      Sorry for the slow reply. The 2.x branch of the repo allows for multiple taxonomies. I’ll be merging that into the master branch soon.

    • Jonathan Daggerhart

      Hi irfan,

      I’ve merged the 2.x branch into master. The readme should describe how to enable for multiple post types. Let me know if you run into any issues.

  • ERT Yazilim

    I prepared a WordPress theme for sale. I used your Taksonomy Term Image project as embedded in this theme. I gave a credit on the introduction page and gave a link to GitHub Project Page. Would you allow me to use your project in this way? What are the terms of use for a WordPress theme designed for sale?

    Thank you.
    Best regards.

    • Jonathan Daggerhart

      Hi Yazilim,

      Sorry for the slow reply. Yes, please feel free to use that project in your theme designed for sale. The credit to my github page is perfect, thank you.

  • Eric

    Can you help with theme integration? I tried and tried to integrate your plugin directly into the theme but have not had any luck. The add image buttons show up but do not work.

    • Jonathan Daggerhart

      The easiest way to use this project would be as a plugin. If you need to include it in the theme because you’re planning to distribute the theme separate from a site, then the best approach would be to place the project within your theme and then include the main plugin file in your functions.php.

      For example: If you place this code in your theme within a directory named “taxonomy-term-image”, then in your functions.php file you would need to add the following.

      if (file_exists( __DIR__ . '/taxonomy-term-image/taxonomy-term-image.php' ) ) { 
        include_once __DIR__ . '/taxonomy-term-image/taxonomy-term-image.php';
  • Johnny

    The button does not open the media library

  • evgeniy

    Good day, help to inject your image output code into my code

    “slug”, “parent” => 0, “hide_empty” => 0)); ?>
    $hiterm): ?>

    cat_ID ); ?>

    <a href="”>
    name; ?>

Leave a Reply

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