Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like to set thumbnails for each tag. I actually need two type of thumbnails. 16 x 16 and 90 x 90.

16 x 16 will be used infront of tag name like stackoverflow. 90 x 90 will be used in tag page as tag avatar. Is there any readymade plugin available?

Can anyone help me? Thanks

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.