How to add/Show Images with WP-Category

Nur . Posted in How-To, Plugins 1050 Views

If you are customizing or designing your theme, you can link images with categories in post. All you have to add some simple PHP code to your WordPress theme with some basic html knowledge and specific images for categories.
First of all you must know about get_the_category tag. You can read detail about what this tag is in the WordPress documentation here.

Here is the code which is good hack for adding images to the categories.

<h3>Posted in:</h3>
<?php foreach((get_the_category()) as $cat)
	{
	$catname =$cat->category_nicename;
	echo "";
	echo "<img src"/wp-content/cat-icons/";
	echo $catname;
	echo ".png" alt="$catname category image" border="0" />\n";
	}
?><br />

I have copied this code from the tutorial Very easy wordpress theme hack show category images, the  writer has well explained about the detail on how to use this code. Also he got inspiration and hacked this piece of code from this link: Styling posts by category and category specific images.

WordPress Plugins for Category Images


Category Icons Lite

The Category Icons plugin is written by Brahim Machkouri, and the author has made a website dedicated to this plugin (http://www.category-icons.com) where you can find many more information like full documentation, FAQ’s and a ‘Troubles’ section where you can ask your questions regarding the plugin.

It’ll work with a lot of themes. Just try. If you have an issue, make sure your template has the post title preceded by the permalink and its title :

<a href="<?php the_permalink() ?>"... title="<?php the_title(); ?>">
<?php the_title(); ?>

or

<a title="<?php the_title(); ?>"... href="<?php the_permalink() ?>">
<?php the_title(); ?>

How to use it :

  1. Deactivate the Category Icons Lite plugin if it was previously installed and activated.
  2. Upload this plugin or install it via WordPress
  3. Activate this plugin through the ‘Plugins’ menu.

Detail | Download

Category Icons

The No. 1 plugin to assign icons to categories easily.

Detail | Download

Category Image(s)

Display an image for each category associated with a post.

This plugin provides the templates tag c2c_the_category_image() which basically reproduces and extends the functionality of WordPress’s core functionthe_category() to add the ability to display a category image instead of the category name in the link to the category archive. With its $image_extensions argument defaulted to "", the plugin could be a drop-in replacement forthe_category(). As is done in the_category(), the image or text for each category is also a link back to that category’s archive.

Detail | Download

Reference:
Excluding WordPress categories
Understanding wordpress categories

Nur

I am a Wordpress, Website Developer and Designer, creator @ WP Arena, Provide Free WordPress consultation and can help to install WordPress in a secure way to small businesses and bloggers.

Free & Professional WordPress Security Service Free & Professional WordPress Security Service

We Love WordPress. WordPress Arena is a place for WordPress Developers and Designers, providing Tips, tricks, tools and resources to build a website or blog on WordPress. We also present The WordPress Showcase for all kind of WordPress Powered Websites.


Copyright © 2014 WP Arena All Rights Reserved

Divi WordPress Theme