How to modify the category icons through functions.php

I’ve created a filter named category-icons in the plugin. I used that filter to add SEO Friendly Images compatibility.

So, if you want to play with it in order to modify the icons (rollover or other thing), you can do that in functions.php of your theme. You’ll perhaps need some knowledge about parsing stuff, but it’s worth it. And if you write some cool functions, why not share them with us ? :-D

Example (a very simple one) : Continue reading

How to remove the border around icons

Sometimes, you don’t want to have a border around the icons. Try one of these solutions :

1. In the posts

In your template file, put the following code if you want no link and no border (most of the time, just ‘link=false’ do the trick) :

get_cat_icon('class=myicons&link=false');

with this added in your style.css file :

.myicons {
 border: 0px;
 border-style:none;
}

2. In the sidebar

Use the put_cat_icons() function. Example :

put_cat_icons(wp_list_categories('echo=0'),'class=myicons');

But you can also use the widget as an alternative, which is easier, but don’t forget to activate it. You’ll need to enter the following parameters in put_cat_icons() field :

class=myicons

with this in your style.css :

.myicons {
border: 0px;
}

3. Use the border parameter

Important ! If you use the border parameter, your page will not be valid XHTML Strict.

In your pages and posts :

get_cat_icon('border=false');

In the sidebar :

put_cat_icons(wp_list_categories(’echo=0′),’border=false’);

In the widget parameters:

border=false

How to add icons to pages/subpages

Update 2 : I’ve written another post on how to do this without any other plugin : How to assign an icon to a page

Update 1 : as the plugin Page Category Plus is not available anymore, nor supported, it’s no longer possible. But You can always contact the author.

The plugin is capable to not only assign an icon to your posts, but also to your pages and subpages.

To do that, you’ll just need to download the Page Category Plus plugin and assign a category to your pages/subpages. Then you’ll be able to manage icons for your pages/subpages from the category icons plugin. Don’t forget to add the get_cat_icon() code to your page.php file.

How to display icons in posts

1. download the plugin and install it.
2. Upload your images to your upload folder. The size of the icons depends on your needs & theme. There’s no recommanded size to use the get_cat_icon() function.
3. Assign icons to your categories in Manage tab.
4. Then, in Template Code, the plugin will show you where to put the get_cat_icon() and put_cat_icons() functions in your theme files :

templatecode.jpg
5. You can also use the widget to display icons in your sidebar.

Note that the ‘small’ icons are displayed by default. If the small icons are not found, the normal icons will be displayed, and vice versa. If you have both type (normal and small) and you want to display ‘normal’ icons, you must use set the parameter ‘small’ to false.

Example :

I want to display ‘normal’ icons in my posts. I’ll put that code in index.php (for example) :

get_cat_icon('small=false');

How to assign an icon to a category

In WordPress 2.3.X :

Go to Manage > Category Icons and click on Icons tab.

Manage icons

In WordPress 2.5 :

Go to Settings > Category Icons and click on the Icons tab.

Manage Icons WP 2.5

In WordPress 2.7+ :

Go to Posts > Category Icons and click on the Icons tab.

Icons tab

Icons tab

If you want to delete the icons of a category and its priority, click on the checkbox in front of it, and then click on the button “Delete Icons and Priority”.

In the “Name” column, click on the name of the category to edit or select its icons.

Select Icons WP 2.5

In the dropdown menu icon or Small icon, select an icon among the ones you uploaded in the default folder (wp-content/uploads) or the folder you’ve choosen to upload them. And then click on the button to the right to validate.That’s all.

How to find where to place the get_cat_icon tag ?

First, remember that the Category Icons plugin just generates images tag, nothing more. Thus, you can first work with an image in your theme, and when you are satisfied, replace that image with the get_cat_icon tag.
Through the Template Tags panel, your template files are scanned and patched if they’re writable. If not, informations about where you should paste get_cat_icon() in your files are displayed : line number and the column number. These locations are just where you COULD paste the tag, not where you MUST paste it. It’s up to you to find the appropriate location within your template files. The tag is usually within the Loop. A blue arrow shows you where to paste the followin code :
<?php if (function_exists('get_cat_icon')) get_cat_icon(); ?>

Nota Bene : If you don’t want your files to be patched automatically, make sure it’s not possible to write into them by checking the permissions.

Template Tags

Template Tags

If you want to place it in another place than in the Loop, you should read this post.