Category Icon Plugin
-
I wanted this to display icons for all of the categories an entry belongs to, so I added a clause that simply loops through them, when the value of $icon_cat = “all”. (I also wanted the icons to link to the appropriate category “page”; which is a hack that won’t necessarily port to other sites’ configurations, so that’s left as an exercise for the reader. {smile})
function icon_picker($text)
{
global $icon_path, $icon_url, $icon_align, $icon_ext, $icon_cat;
$content = '';
$cat_names = array();
$cats = get_the_category('');
if($icon_cat == "all")
{
foreach($cats as $category)
{
$cat_to_use = stripslashes($category->cat_name);
if(file_exists($icon_path . $cat_to_use . $icon_ext))
{
$filename = $icon_url . $cat_to_use . $icon_ext;
$content .= "<img class='caticon' src='" . $icon_dir . $filename . "'";
$content .= " align='" . $icon_align;
$content .= "' alt='" . $cat_to_use . " icon' hspace='5' />n";
}
}
$text = $content . $text;
} else {
foreach ($cats as $category)
{
$cat_names[] = stripslashes($category->cat_name);
}
if($icon_cat == "first")
{
$cat_to_use = $cat_names[0];
} else {
$size = sizeof($cat_names);
$cat_to_use = $cat_names[$size - 1];
}
if(file_exists($icon_path . $cat_to_use . $icon_ext))
{
$filename = $icon_url . $cat_to_use . $icon_ext;
$content .= "<img class='caticon' src='" . $icon_dir . $filename . "'";
$content .= " align='" . $icon_align;
$content .= "' alt='" . $cat_to_use . " Icon' />n";
$text = $content . $text;
}
}
return $text;
}
if anyone (especially you tverbeek) could help me with linking the image to the category, that would be amazing. I’m trying to use WP as a CMS for my site, so I’m getting the posts and categories to work the way I’d like before changing the theme, and I’ve got the image to appear (hopefully it will always display the image I want), but I’d like it to link to that category. I know NOTHING about PHP so any help would be greatly appreciated.
oh, if you want to see what i’ve got so far, go to https://www.antonskey.com/punkcanada/wordpress
does anyone know if this works for version 1.5.1.2?
thanks!I HIGHLY suggest using the following plugin:
https://www.coffee2code.com/wp-plugins/#categoryimages
Easy to install, to use and oh so nice. Links back to the category too ??
The plugin was working perfectly before I wanted to use permalinks
My category url is: https://www.turbofsi.net/audi/
but the category icon is linked to : https://www.turbofsi.net/category
??bump
Is this plugin still being supported? The developer’s site is down as far as I can tell. I have tried using ‘category images’ instead, but I want the image to show up in the post as well as in the sidebar. As far as I can tell ‘category images’ can’t do the sidebar.
I’m trying to use this but the screen that should allow me to upload icon files just has a pull down menu that says —no icon— and no upload options. I’ve left the local, URL, and filetypes fields blank in the options screen and I’ve tried filling them in. Nothing works.
When I view source for the page that should be allowing me to upload the icons I see this hidden away:
<b>Fatal error</b>: Call to a member function on a non-object in <b>/home/sandarac/public_html/wp/wp-content/plugins/category_icons.php</b> on line <b>322</b>
What’s happening here?
- The topic ‘Category Icon Plugin’ is closed to new replies.