A new free WordPress plugin that adds WordPress Category Images has just been released on the official WordPress plugins directory. Categories Images easily allows you to add WordPress Category Images to a WordPress category or even a custom taxonomy. In this article I will go over how to use this plugin on your own website to add WordPress category images to your WordPress website.
STEP 1: Install Categories Images The WordPress Category Images Plugin
The easiest way to install a WordPress plugin is to simply go-to your WordPress admin panel and then Plugins > Add New. Type in Categories Images into the search box and click search plugins.
Once the search has completed it should be the first plugin listed in the returned results. Now simply click Install Now and the Categories Images plugin will be installed.
If you would prefer to download the Categories Images plugin in a zip format from the WordPress Plugin Directory you can do so via the link below.
STEP 2: Edit Your Themes category.php With Image Code
To actually display the images we want on our category pages you are required to add some code to your themes category.php file. We used the WordPress default twentyeleven theme for this tutorial but your existing theme should work the same.
The default code below is what the plugin author supplies to be inserted into your themes category,php. The code below however will only return the URL of your category image and not actually display an image.
<?php if (function_exists('z_taxonomy_image_url')) echo z_taxonomy_image_url(); ?>
To display the image correctly we need to add some HTML code to the code above, whilst we are at it we will also add a simple alt=”” tag for better SEO. This code snippet below will now achieve our goal of actually displaying the image on our category pages.
<?php if (function_exists('z_taxonomy_image_url')) { ?> <img src="<?php echo z_taxonomy_image_url(); ?>" alt="<?php the_title(); ?>" /> <?php } ?>
Insert the code snippet above into your themes category.php file somewhere near the top of the page. Usually a good position to place this code is under the category page title, look for an H1 tag within your template file which will usually contain the page title and paste the copied code below it.
Dont worry if you get the placement wrong the first time you can always move the code around until you get a suitable display position. Once happy save your themes category.php file.
STEP 3: Adding Images To Your WordPress Categories
Now that you have the plugin installed and the code required to display the category images in our themes category.php file has been inserted you can begin to add images to your WordPress categories.
Go-to your WordPress admin panel then Posts > Categories, when adding or editing a category you will now see an input field where you can upload an image.
Click on the image upload field and you get a pop-up with the WordPress media manager panel where you can upload your category image.
Choose your image and upload it, when uploaded click insert into post and your category image will be inserted into the empty image field. Save your category and go and view your newly uploaded image.
Conclusion
In this article I only showed you how to add images to your WordPress categories, the Categories Images plugin will also allow you to add images to post tags and any custom taxonomy you or an installed plugin creates. When the Categories Images plugin is used in conjunction with the WordPress category description text and styled with some HTML & CSS you can create some nice category information headings.
This plugin is pretty good although it could do with a configurable image size option which it is lacking at the moment, hopefully a feature we will see in future updates of the plugin. If your looking for an easy way to add WordPress Category Images the Categories Images plugin could be a good minimal solution for your project.
Leave a Reply
You must be logged in to post a comment.