How to set thumbnail for each tag?

There are several plugins that allow you to attach images to categories/tags/taxonomy terms. Try googling taxonomy images site:wordpress.org/extend/plugins (the last part restricts the search to the WordPress plugin repository) and you’ll find a variety of recently updated plugins, including:

Here’s what it sounds like you need:

  1. An interface for uploading an image in the WordPress admin.
    All of these plugins provide that.

  2. Inclusion of relevant image in tag archive pages. Some of the available plugins will do this automatically. If not, they provide template tags and/or shortcodes to insert them yourself, which you can do one of two ways: 1) insert the template tag into the theme file in charge of your tag archive pages (usually tag.php); or 2) use a filter or action hook with a custom function in your functions.php file.

  3. A way to get your archive page image to show up at the desired size. Some of these plugins provide sizing options or use WordPress’s native image size settings. Another approach would be to control the size of the image using CSS; another approach, and probably the most direct one, is to crop them to your desired size yourself before uploading.

  4. A way to insert a mini 16 x 16 icon into your tag lists. I didn’t see any plugin that does this automatically (though there is a plugin that does this for categories). You may be able to find one yourself, but if not, you could achieve this with a custom get_the_tags() loop, something like this:

 $posttags = get_the_tags();
 if ($posttags) {
   foreach($posttags as $tag) {
     echo '<img src="http://example.com/path/to/icons/' . $tag->term_id . '.jpg" 
 alt="' . $tag->name . '" />' . $tag->name . '<br />'; 
   }
 }

(This would require your icons to be saved in /path/to/icons/ with [term id].jpg as their filename. You would obviously change as much of this as necessary to meet your needs and settings.)

You would then replace whatever code is currently used in your theme to display tags with [your version of] the code above. In Twenty Eleven, for example, you would have to modify code in the content-single.php file around where it says $tag_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );. In other themes it might be in post.php or single.php.

Note that all themes are different, and you will have to customize the code in various ways to get keep the logic and design of your theme intact.

So: while we don’t have a ‘readymade’ solution, my hope is that these notes help familiarize you with the thought processes and technical processes involved.


For a note in the Codex on showing tag images: http://codex.wordpress.org/Function_Reference/get_the_tags#Show_tag_Images

For a quick introduction to WordPress hooks and filters:
http://wp.tutsplus.com/tutorials/plugins/reel-em-in-understanding-hooks-from-the-inside-out/

The Codex page on template hierarchy, which is what determines which template files are used to display which content: http://codex.wordpress.org/Template_Hierarchy