Categories Images is a WordPress plugin which allow you to add an image for each category (or term), it is so easy to user. This plugin will create a new text input that will had the image url of the category, in both forms when adding a new category or edit an existing one, you can put a url for the image or upload it bu click on the text input.
Installation:
- Open your wordpress admin panel, then plugins menu > Add New and search for ‘Categories Images’.
- Click to install.
- Once installed, activate and it is functional.
Or you can install in manual:
- Download the plugin from WordPress Plugins.
- Extract it, then upload the extracted folder ‘categories-images’ to ‘/wp-content/plugins/’.
- Go to your wordpress plugins menu, then activate it.
<?php if (function_exists('z_taxonomy_image_url')) echo z_taxonomy_image_url(); ?>
<ul> <?php foreach (get_categories() as $cat) : ?> <li> <img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /> <a href="<?php echo get_category_link($cat->term_id); ?>"><?php echo $cat->cat_name; ?></a> </li> <?php endforeach; ?> </ul>
If looping for taxonomies:
<ul> <?php foreach (get_terms('your_taxonomy') as $cat) : ?> <li> <img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /> <a href="<?php echo get_term_link($cat->slug, 'your_taxonomy'); ?>"><?php echo $cat->name; ?></a> </li> <?php endforeach; ?> </ul>
If your post had more than one category and you want to loop for all post categories use the following example:
<ul> <?php foreach (get_the_category() as $cat) : ?> <li> <img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /> <a href="<?php echo get_category_link($cat->term_id); ?>"><?php echo $cat->cat_name; ?></a> </li> <?php endforeach; ?> </ul>
And if your post had more than one taxonomy and you want to loop for all post taxonomies use the following example:
<ul> <?php foreach (get_the_terms(get_the_ID(), 'your_taxonomy') as $cat) : ?> <li> <img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /> <a href="<?php echo get_term_link($cat->term_id, 'your_taxonomy'); ?>"><?php echo $cat->name; ?></a> </li> <?php endforeach; ?> </ul>
if there were any bugs or you faced any problems please reply to this post, if I had more time I will update this plugin and add more features.
update 26-07-2012: I had noticed that there is some people talking about my plugin, here is a link to the post
http://wpshock.com/wordpress-category-images-taxonomy-images-plugin/
update 06-10-2012: Finally I got some time to test the plugin in WordPress MU and now I confirm that the plugin works so fine whether you choose to activate the plugin by blog or using network activation from your network control panel
update 25-01-2013: A great update had been made to this plugin, and hope you liked it, Thank so much to Joe Tse http://tkjune.com