Plugin: Category Image(s)
http://coffee2code.com/wp-plugins/category-images
- c2c_the_category_image() basically extends the functionality of WordPress’s core function the_category() to add the ability to display a category image instead of the category name in the link to the category archive. The function with its $image_extension argument defaulted to ” could be a drop-in replacement for the_category().
- As is done the_category(), the image or text for each category is also a link back to that category’s archive.
- If
$image_extensionsis defined, but no image is found for the category, then nothing is displayed for that category. - The images must be given a nice-name version of the category name. This means all non-alphanumeric characters must be stripped from the name, all letters made lowercase, and all spaces replaced with ‘-’. For example:
Category name ==> Nice-name to use for filename :
WordPress ==> wordpress
Scott’s Plugins ==> scotts-plugins - The number of category links/images displayed can be limited via the $limit argument
- Category a image <img> tags are defined with
class="catimage"for stylesheet manipulation - No global site-specific settings need to be configured.
- Must be run inside “the loop.”
- Download the file category-images.zip and unzip it into your wp-content/plugins/ directory.
-OR-
Copy and paste the the code ( category-images.phps ) into a file called category-images.php, and put that file into your wp-content/plugins/ directory. - Activate the plugin from your WordPress admin ‘Plugins’ page.
- Create category image (.png unless you specify the extension in your call to c2c_the_category_image()) for each category you wish to have an image for, placing the image into the wp-content/images/ directory (unless you specify another location in your call to
c2c_the_category_image()). Remember to give the filename the nice-name version of the category name (see note above). - Modify your index.php at a point within “the loop” to make use of the function (assuming, of course, you’ve already defined categories and assigned posts to them). The simplest use would be to replace the index.php call to
the_category()withc2c_the_category_image()
function c2c_get_category_image($category, $image_extensions='png gif jpg' $image_dir='/wp-content/images/')
This is a helper function that retrieves the URL of the image for a specified category. Returns ” if no image was found:
- $category : array for a single category
- $image_extensions : (optional) a space-separated list of image extensions to consider for use for the image(s) to be displayed, in the order they are to be considered; if defined as ” then no image is retrieved and the category name is displayed instead (a la the_category()); default is ‘png gif jpg’
- $image_dir : (optional) the directory in which to look for the image(s); default is ‘/wp-content/images/”
function c2c_the_category_image($seperator='', $parents='', $image_extensions='png gif jpg', $image_dir='/wp-content/images/', $use_name_if_no_image=false, $start_from='begin', $limit=999)
This function does the actual display of the post’s category image(s):
- $separator : (optional) text to insert between each image to be displayed (examples: ‘, ‘; ‘<br />’); if defined as ” (which it is by default), then like the_category(), it will display the image(s) in an unordered list.
- $parent : (optional) honestly, I’m not quite sure if/when this argument is ever used or what it’s meant for, but I’ve taken it into account; default is ”
- $image_extensions : (optional) a space-separated list of image extensions to consider for use for the image(s) to be displayed, in the order they are to be considered; if defined as ” then no image is retrieved and the category name is displayed instead (a la the_category()); default is ‘png gif jpg’
- $image_dir : (optional) the directory in which to look for the image(s); default is ‘/wp-content/images/”
- $use_name_if_no_image: (optional) if no image for a category is found, should the name be shown instead?; default is ‘false
- $start_from : (optional) display images starting from the ‘begin’ or the ‘end’; default is ‘begin’
- $limit : (optional) the maximum number of images to display for a post; default is ‘999′
- You can opt to treat only certain categories as having a graphical representation by defining an image for them but not creating images for the non-graphically represented categories (as in you can have a subset of categories that dictate what image to be displayed for the post)
- You can take advantage of the $image_extension and/or $image_dir arguments to display different category icons under different contexts, i.e. if showing a $single post, choose to use a ‘png’ image, otherwise use ‘gif’; or locate your images in different directories ‘/wp-content/images/cat-images/small/’ and ‘/wp-content/images/cat-images/large/’ and decide on context where to get the image(s) from:
// In showing the post singularly, then use a larger image, else use a small image <?php if ($single) { c2c_the_category_image('', '', 'gif', '/wp-content/images/cat-images/large/'); } else { c2c_the_category_image('', '', 'gif', '/wp-content/images/cat-images/small/'); } ?>
// Show all images in a comma-separated line <?php c2c_the_category_image(', '); ?>
- WordPress Support Forums announcement of Category Image(s)
- 17 May 2005: v1.2 released — Compatibility fix for WP1.5.1
- 23 Mar 2005: v1.1 released — Same as v1.0 but compatible with WP1.5+
- Change to accommodate new get_category_link() arguments
- 23 Mar 2005: v1.0 released — Last version compatible with WP1.2. Changes include:
- Added argument $use_name_if_no_image=false to allow showing cat name if no image was located
- Tweaks to update c2c_the_category_image() with changes made to the_category() (mostly rel= stuff)
- Changed default category images directory from /wp-images/ to /wp-content/images/
- 12 Oct 2004 : v0.92 released — Fixed a pair of typos that prevented images from showing
- 23 Sep 2004 : v0.91 released —
- Now supports listing multiple image extensions
- Prepended all functions with “c2c_” to avoid potential function name collision with other plugins or future core functions… NOTE: If you are upgrading from an earlier version of the plugin, you’ll need to change your calls from
the_category_image()toc2c_category_image() - changed from BSD-new license to MIT license
- 27 Jun 2004 : v0.9 released to the public
Copyright (c) 2004-2005 by Scott Reilly (aka coffee2code)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

I’ve seen other category images plugins, but this is the first that is supposed to do what I want (put in place of list with link). But I am having some trouble, no matter what I seem to do, I get “Filed under: -” etc… it just removes the category completely. Am I calling it correctly with the_category_image(’, ‘); ???? Thanks!
My examples might’ve been unclear about the need to make sure you call the function within the php tags, like so:
<php the_category_image(', '); ?>
I just updated the examples above to make that explicit. Just bringing that up to rule it out as the problem…
Later…
Ah, I just followed the link to your site and saw that you figured out the problem. I completely neglected to mention that the images needed to have the nice-name version of the category name (I now explain it above.) Sorry for the lack of documentation on that.
BTW, I like your use of the plugin!
Thank you for the kind words

I just have two things to say: I LOVE WORDPRESS & I LOVE THIS PLUGIN!!
lol - this has opened the door for me to use multiple categories, a thing I stayed away from before. Don’t ask me why, I just did… lazy I guess. hehe
So many things to see on this site… oooh I’m having fun
At the risk of looking like an even bigger idiot, I have another question.
Okay the plugin was installed and working great, but then I had to create a new category. I created it, posted in it, added a new image for it but nothing turns up. I tried reposting again in it after the image was in there. Tried removing that category and putting it back. Also tried deactivating the plugin and then reactivating it. Everything and I still got nothing. I only got listed the other category of the post. Any clue as to what’s going on and how I can fix it? Thanks
Hey I don’t mind answering questions. Offhand I’m not certain what the problem is. How do you have your categories structured? Anything new about how you handled this latest category? Namely, do you have it as a sub-category of one of the others? If it’s a subcategory, is it the first sub-category you’ve used? Does its parent category have any posts associated with it? I know you’re aware of the need for nice-naming the image files, but does this new category have something unusal about its name that you might not have nice-named properly?
Finally, just to see what happens, when you call the_category_images(), try calling it with its
$image_extensionargument set to ” (two single-quotes without a space in-between). You should see the text names of the categories instead of the images.Okay well - it’s not anything wierd, as a category. It’s just Books, and the image is Books.png. I have a couple of subcategories, but I have not used them yet and they are not connected to this new category. So I don’t think I did anything wierd. I did what you said with the text names and I get those names okay, both categories.
Blah… lol confusselled.
The image filename needs to be all lower-case, books.png. Could that be what gets it working for you?
Well, no that was not the problem, but I finally figured it out. And now I feel like a real dumb@$$. LOL. *Too embarrassed*
Your plugin is great!! And it worked like a dream on the first attempt!! Thanks for making it!
1) Yep
2) Done, fine
3) Uploaded, lowercase, cat name OK, good
4) What? “Modify your index.php …” What am I adding to the index file?
These instructions don’t make it clear … so, er, help?
Well, the simplest usage would be to replace the existing call in index.php to the_category():
<?php the_category() ?>
with a call to the_category_image():
<?php the_category_image(', ') ?>
Naturally, you may want to adjust the function arguments to suit your specific usage, and you may want to change where in index.php the category images should appear, but doing the above should be a start.
Ah, I see Scott, I just didn’t get that from following the instructions; please add a line in saying this so others don’t try your plugin and just wander off wondering what to do. Thanks for the prompt assistance!
Now on to the tweaking my index file … where did I place the hammer …
Hello… Nice plugin and I’m trying to use it but seem to be having some trouble. I can’t get the images the show where I made the function’s call…in fact, they don’t show at all. In the plugin itself, I’ve pointed the directory to ‘wp-images/cat-images/’ because that’s where they are stored (.png format). So can you help me out?
my site http://www.zillasays.tk. And the category images are supposed to show before the word “Posted.” Thanx.
I can’t seem to reach your site. My first theory about the category images not showing would be: have you given the category image files the “nice-name” of the category names? For instance, if your category is “Family News!”, the file would be family-news.png (the filenames must be ONLY alphanumeric characters, all lowercased — no punctuation; spaces replaced with “-”).
is it possible to work this code:
I have this huge amount of white space before the post … But it would be sweet if the icon was in the (upper right) of each post and the text of the post went around it.
?php the_category_image(', ') ?>into the actual text of every post? that way it would look more likeCan this be done? if so how?
sorry… more like slashdot.
You would most likely want to use CSS to control where the image(s) appear. Not sure how much you know about CSS; I’m no guru, but I could look into it.
yeah any advice would be super helpful… I don’t know much about CSS… Did you find anything?
hi scott and thanks for this great plugin
one question. is it possible to use it to replace each category name by its image in the category list of the nav bar (fonction:
wp_list_cats()) and if so, how?thanks a bunch
Questions?: The CSS turns out to be pretty simple. After looking at the page you sent me, it looks as though you have something like this in your index.php:
(granted, you may have supplied arguments to the_category_image()).
All you need is for it to look like this:
But in addition, you need to add this to your CSS file (most likely wp-layout.css):
If you want a bit of space around the image, add in something like
margin: 2px;to that CSS block.Jean-Pascal: Unfortunately the plugin wouldn’t do much for you in listing the categories by image outside the loop (on the sidebar like you want), except as code reference if you were hacking on your own. I’ve been meaning to modify wp_list_cats() to use images and hope to get around to it soon.
Scott, when trying to validate the HTML it get the recurring error
If I understand correctly an block-level element like
is not allowed inside an inline element like . However that how it is coded in the plugin’s template-functions-category.php file. Any idea?Thanks
Plugin updated to v0.91
This update features:
* Now supports listing multiple image extensions
* Prepended all functions with “c2c_” to avoid potential function name collision with other plugins or future core functions… NOTE: If you are upgrading from an earlier version of the plugin, you’ll need to change your calls from
the_category_image()toc2c_category_image()* changed from BSD-new license to MIT license
Jean-Pascal:
Have you defined the first argument to the function? If you don’t, the function will automatically format using
<ul>. You can specify something simple, like a single-quoted space as the first argument (the$seperator) :<?php c2c_the_category_image(' '); ?>
(I’m using the new function name there, but the way the arguments work is the same with the version of the plugin you have.)
[…] ged a few things around to make it more like what I wanted. If you’ve got WordPress, go to Scott Reilly’s site and get
[…] ged a few things around to make it more like what I wanted. If you’ve got WordPress, go to Scott Reilly’s site and get
I just upgraded to the new version and am using the following code and it never returns an image, the image is called {category}.png and its in /wp-images/categories/ … anyone see anything wrong that I am missing?
< ?php c2c_the_category_image(', ', '', 'png', '/wp-images/categories/'); ?>
it didnt add my code sooo uhhhh …
<?php c2c_the_category_image(', ', '', 'png', '/wp-images/categories/'); ?>wow …
<?php c2c_the_category_image(', ', '', 'png', '/wp-images/categories/'); ?>Plugin updated to v0.92
This release fixes a pair of typos that prevented properly referenced images from appearing on a site.
This should fix your problem, BoBB.
[…] , gallery.idahocline.info Some new internal stuffs (plugins as Customizable post listing, Category images and … e you soon … on another server…. […]
I may have missed it, but if I have only an image for one of the categories where a post has multiple categories, is there a way to display the other category names after that image in text form?
BB: You’re correct in that the plugin does not allow the intermingled display of category icons and category names. It should be easy enough to add though. If you want to try it out while I consider changing the plugin to support the request:
In the plugin’s file, there are two instances of this line:
if (empty($image_url)) { continue; }Replace each of them with:
if (empty($image_url)) { $category_display = $category->cat_name; }Note that the above change makes the plugin output the category name if no category image is present. If I add this to the plugin, I’d also add an option to control the behavior.
I really like this plug-in, and it’s relatively simple to implement. I have been having a slight problem with it, although it’s more an annoyance than a problem. Whenever I edit a category, or create a new one and click the “add category” button, it brings me to an error page which says this…
Warning: Cannot modify header information - headers already sent by (output started at /home/.odelia/lotraimant/greenkri.com/blog/wp-content/plugins/category-images.php:152) in /home/.odelia/lotraimant/greenkri.com/blog/wp-admin/categories.php on line 134
I tried returning to my wp-admin, and the changes had been implemented with no problem. It’s just annoying to be hit with that error message every time, then having to return to my wp-admin. Does that make sense?
Then again, it seems to create this error message when I post or edit a post….
Warning: Cannot modify header information - headers already sent by (output started at /home/.odelia/lotraimant/greenkri.com/blog/wp-content/plugins/category-images.php:152) in /home/.odelia/lotraimant/greenkri.com/blog/wp-admin/post.php on line 342
Kristen: That error is common when there are spaces and/or other characters in the file before the
<?phpthat should mark the very beginning of the code, and/or after the?>that marks the very end of the code. Check out the category-images.php file and make sure there aren’t those spaces. If you continue to get the error try extracting the plugin file from the .zip.Thanks for the help, that was the problem. One itty bitty space at the end. I should have known this was the answer too, because I’ve had a similar problem with something else.
Again, thanks.
Doesn’t work on PHP 5.
Lunks: I don’t run PHP 5 so I have to take your word for it. If you’ve figured out why, I’ll be glad to incorporate the changes.
Followed the directions for installation in WP 1.5, engaged, pasted the function, uploaded the images, added the CSS…works as promised.
im a bit confused. i want to actually put a different image in the header section for each category.
and im using 1.5 strayhorn.
what would i do differently?
Works like a charm, though I had to do a little hacking (I added an align=left to the img production code to get it inline with mytitle the way I wanted.)
One question, though. If you go to my site, you’ll see that the title text says “View all posts in Comics” but clicking doesn’t actually do that, since it seems to have cat=0 in the URI. My site is WP1.5 Strayhorn, is that the reason? Any suggestions on how to get it to do the right thing?
Thanks!
Dave
I´ve updated my local mirror from 1.2.2 to 1.5 Strayhorn, and the Category Images plugin still shows the proper images, but the link for ALL category images goes to /index.php?cat=0
Tech specs:
Mac OS X, 10.3.7
php 4.3.10
Any guesses?
I run php 5.0.1 on my hosting account will it work there?
[…] ss. Also many thanks to the folks who tested out comment stuff, critiqued design, and to this guy for his Category Images plugin that got me my topc icons back! […]
“I run php 5.0.1 on my hosting account will it work there? ”
Sadly it didn´t work there either. Any thoughts?
Thanks
Nick.
Nick: There is an updated version of the plugin in the dev.wp-plugins.org repository. I plan on officially announcing the update soon, but if you like you can try it out in advance by downloading it from here. Let me know if that is any better for you.
Thanks Scott. I´m using it now, but I am sorry to say that it seems acts the same as the previous one in my case, on both my local mirror, and on the remote server. May I be doing anything wrong?
All the category links are “cat=0″ even though the link title shows correctly, e.g. I have more than 1 categories. Nothing unusual on the installation — ISP hosted on PHP 4.3.10, WP 1.5 S. I have the call just after:
In my index.php default theme. The call is:
Aesthetically I am very happy with this plugin! Would love to resolve this little bug.
All the category links are “cat=0″ even though the link title shows correctly, e.g. I have more than 1 categories. Nothing unusual on the installation — ISP hosted on PHP 4.3.10, WP 1.5 S. I have the call just after:
div class=”post”
In my index.php default theme. The call is:
?php c2c_the_category_image(’ ‘, ”, ‘png’, ‘/wp-images/cat-images/’); ?
Aesthetically I am very happy with this plugin! Would love to resolve this little bug.
Hey Scott, just wanted to confirm the above (ie all categories go to 0). The thing is I’m not having that problem on my local server, which is running on a beta of WP1.5 but a pretty recent beta, my normal site is running the stable release.
Seriously thanks for all your work for the plugins you’ve done, brilliant work on all fronts.
Great plugin, very easy to implement. One question. Is it possible to display the category image as a background to the post, allowing the text to flow over the image??
I think that WordPress 1.5 changed underneath you, and left this version of the plugin (0.92) slightly broken.
The category ID generated in the links is always zero.
I think this is because the get_category_link() function changed; all the old code I’ve seen uses three parameters - a zero, the category ID, and the “nice name”.
The new version from WP 1.5 appears to only use the category ID.
Thus, all the links wind up as cat=0.
It’s an easy tweak, I think. After having made it, the category IDs on my page work properly in WordPress 1.5.
(Mind you, I’ve only been using Word Press since 1.5, and only for about a week, so I may be wrong… but the code itself was pretty clear.)
Sorry Lou could elaborate what the tweak is?
Lou: Thanks for figuring out the problem! Turns out
get_category_link()was changed the day before WP 1.5 was released, but by then I had already tested the plugin against 1.5 and it had worked.khaled: Try the latest from the dev.wp-plugins.org repository and let me know if that works for you.
Is there a way to use it as a background image to the post?
Glad to have helped, Scott. It’s a neat plugin.
Darn those moving targets, anyway! =)
I do think that the code is a little messed up when it comes to using the “parent” option. It works fine if it’s blank or caught by the “default” value, but if you try and use “single” or “multiple” then the output is fairly strange.
Have you had a chance to look at this, or would you like me to have a longer (more than reading through the code) look at it?
At the moment, I’m using ” on my site, and then also using the text-based category function to get the other display, so it isn’t a problem for me, but it might be for others.
I’d be happy to have a look at it.
Joe: Possible? Yes. In an easy and direct manner? Probably not. The function can assist you in obtaining the category image file location (by calling
c2c_get_category_image()with the appropriate category ID and other arguments). However, you would need to introduce a bit of CSS to make the image the background image for just that post, which is a bit beyond the scope of this plugin to do. Here’s a top-of-my-head solution that hasn’t been tested:In index.php, you should have a line like this:
<div class="post">Change it to something like:
This approach makes some assumptions (i.e. that only the first category retrieved is the one that is supposed to have an image) and very likely doesn’t work exactly as I wrote it out, but it should be close. I think.
Lou: If you have a chance to look it over, please, by all means feel free! I’m swamped with stuff at the moment. To tell you the truth, I haven’t fiddled with the “parent” option much. I used WP’s
the_category()as the basis for this function and tried to minimize the number of changes I did in introducing the ability to handle images.I’m trying like crazy to get this thing work on my site. I can get the default category to show up but none of the others. I have updated to the 1.1 version of the plugin with no luck.
Please help me. My wife really want’s this on her site!
Didn’t mess with it much but it keeps giving me T_Variable errors. I don’t know much php but I’ll learn what I need to. Thanks a million for the tip, I appreciate it. Awesome plugins man. How would one learn to write plugins? Learn the API? Just curious.
hi there. great plugin. i am in the process of switching my blog to wp 1.5 and decided to use only plug-ins from now on. i used to handle my category icons via my-hacks. now i have two questions:
1. is there any way to call 2 tags from the title=”" tag? i used to be able to call $category->cat_name and $category->category_description. now this does not seem to work somehow. how can i do that?
2. i noticed that there is quite a big white space between icons if there are several categories to a post. is there any way to reduce that space? it looks like two spaces now, i would like to have them line-up without space inbetween.
cheerz…
I’m going to hate myself for asking this I’m sure, but I’m not getting the output I expect. I see the images, and there is a link, BUT all the links, no matter what image (category) are to http://www.clarkburbidge.com/index.php/archives/category/. The pertinant part linking you to that actual category is missing. Please break it to me softly. I have a feeling it’s right under my nose.
I would also like to have the code post a top image and a bottom image for rollover purposes. Anyone got any ideas of how I’d tweak the plugin to do so..?
This is great. Version 1.1 is spot on and works as promised. I am going to thank you again. SE.
I guess I don’t hate myself. The version for WP 1.5 on 3.25.05 fixed my problem. The generated links now connect to the right category instead of just http://www.clarkburbidge.com/index.php/archives/category/. Thanks! Now if you could just fix my CSS.
Plugin updated to v1.1
Changes:
* Added argument $use_name_if_no_image=false to allow showing cat name if no image was located
* Tweaks to update c2c_the_category_image() with changes made to the_category() (mostly rel= stuff)
* Changed default category images directory from /wp-images/ to /wp-content/images/
* Change to accommodate new get_category_link() arguments (fix necessary for the plugin to run in WP1.5)
v1.0, the last version of this plugin compatible with WP1.2 (basically the same as v1.1 except without the necessary changes to make it WP 1.5 compatible), is available via dev.wp-plugins.org at http://dev.wp-plugins.org/browser/category-images/tags/v1.0/
NOTE: v1.1 and beyond are no longer compatible with WP 1.2.
why mine its not working??
[…] watched last nite!! SEPET! « Hackers pleasure Category image http://www.coffee2code.com/archives/2004/06/27/plugin-category-images/ Leave a Reply Name (required) Mail (w […]
[…] ory-images Monday, April 25, 2005 @ 3:46 pm in Plugins, Wordpress Category-images???????????????? […]
Scott-
I’ve been trying to get category images in the sidebar, but it’s been very difficult. I read your post from September that you’re looking to make this work with wp_list_cats, but I guess that hasn’t happened yet.
Is there any way, ugly as it may be, to hack this functionality?
I’m searching for the same like Scott…Category images in the Sidebar…is ther any other plugin?
THis plug-in seems broken in WP 1.5.1…can anyone else confirm?
I found the fix. Just replace
category_idwithcat_IDthroughout.[…] yIcon: Añade una imagen a cada entrada de la bitácora según la categoría del post. […]
[…] yIcon: Añade una imagen a cada entrada de la bitácora según la categoría del post. […]
Hey,
I was wondering if you have any plans of making this compatible with WP 1.5 or higher. I’d really like to be able to use this plugin. If you know of any other Category Image plugins also, please let me know.
Thanks.
-Brendan
Plugin updated to v1.2
The plugin has been updated to include a fix making it compatible with WordPress 1.5.1.
As for the sidebar requests, that will have to wait until a subsequent release.
Hi! There is no the_category_image() function on WP1.5.1 index.php file, so… Where should I insert the c2c_the_category_image() function? Thanks!
jors: What you want to look for in index.php is this line:
<?php the_category(', ') ?>That’s what you want to replace with something like:
<?php c2c_the_category_image(', ') ?>Ok Scott, thanks for your time. But I’ve only found the the_category() function on wp.php file since WP 1.5 (1.5 & 1.5.1) and change it there. Anyway, I activated the plugin, and WP is throwing to me the following errors:
| |
Warning: Cannot modify header information - headers already sent by (output started at /home/enchufad/domains/enchufado.com/public_html/wp-content/plugins/category-images.php:1) in /home/enchufad/domains/enchufado.com/public_html/wp-admin/admin.php on line 10
Warning: Cannot modify header information - headers already sent by (output started at /home/enchufad/domains/enchufado.com/public_html/wp-content/plugins/category-images.php:1) in /home/enchufad/domains/enchufado.com/public_html/wp-admin/admin.php on line 11
Warning: Cannot modify header information - headers already sent by (output started at /home/enchufad/domains/enchufado.com/public_html/wp-content/plugins/category-images.php:1) in /home/enchufad/domains/enchufado.com/public_html/wp-admin/admin.php on line 12
Warning: Cannot modify header information - headers already sent by (output started at /home/enchufad/domains/enchufado.com/public_html/wp-content/plugins/category-images.php:1) in /home/enchufad/domains/enchufado.com/public_html/wp-admin/admin.php on line 13
Any known issue with this? Thanks.
What is the feck’n deal with your
boxes man.. how are w supposed to copy any of your examples from the web page???Crazy.
i get the same error that jors is getting
I’m getting an error that is confusing the hell out of me.
Parse error: parse error, unexpected T_STRING, expecting ‘&’ or T_VARIABLE or T_CONST in /home/virtual/site121/fst/var/www/html/rantfarm.net/blog/wp-admin/admin-functions.php on line 56
I was able to have the category text and the image appear at the same time but for some reason, i removed that code and now i’m stuck. I want to have both category title and image appear at the same time. can someone please help?
by the way, that error only happens when i click the Edit Post link next to any post. I removed the category image code from my index.php because i didn’t want my whole blog to be down because of this.
I have copy/pasted your code exactly as it appears in the file to my server but it isn’t working. it gives me this error message:
Filed under:
Fatal error: Call to undefined function: c2c_the_category_image() in /home/virtual/site121/fst/var/www/html/rantfarm.net/blog/wp-content/themes/benevolence/index.php on line 13
I’m not a php coder, so I don’t know if I’m asking for something difficult, but would it be possible to set this to allow for different images in different themes? I think all you’d have to do would be change the default to look for a catimages directory in the active theme directory, but I suppose I’m not really certain that’s the case.
Ok I installed wordpress for a friend and he asked me for the icon category plugin.. I installed it and it works but I would like to change some things… you can see the result at http://www.telefilm-central.org/tru/
1. I don’t want that blu border around the image… it really looks bad…
2. I would love the image on the right of the text with the text all around it not above it…
What should I do?
Well, I followed the instructions, named all the files correctly, and the only place I could find the_category() was in wp.php, so I changed it there. Unfortunately, the category images are not being shown still in 1.5.1.
I can’t think of anything. Anyone have any ideas?
Hmm, I must be a total newb, because I’m not seeing which index.php I’m supposed to change. I’m assuming it’s the index file in the currently used theme. But the one I’m using (Connections) doesn’t use the get_category function. The Default theme does, so I switched to that theme, edited the index.php, activated the plugin. Nothing.
My server has WP 1.5.1.2.
I’m trying to get this to work, but nothing is happening. Can one of you techie people please post a simple example in plain english and maybe provide some sample files. All of this back and forth with broken code is causing my eyes to cross…
Excellent plugin - thanks!
I thought I’d give a very small correction to some CSS advice above. On my site, http://hacktopia.org, I wanted a slashdot-like appearance… I wanted the text flowing around the image, which would be in the upper right. I’m very new to CSS, but after playing around for a bit, here’s what worked:
yeah i get the same problem as jors
I’cant find get_category within index.php but wp.php
simply cant find the_category() within index.php of theme “fastrack” from http://www.wpthemes.info/.
Thx for attention
oooops..
with my current theme i cant find “the_category” tag within “index.php
just like jors said
simply my theme’s index.php does not contain the_category string…
any workaround ?
Cool, got it working now! Very nice. Would be nice to get the parent option working. I’ve got one sub-category that I would like to have inherit the category image from its parent.
Pretty cool stuff.
I love this plugin, but I cant seem to get it working. Im using WP 1.5.1.3 and I’ve done all the instructions above…made sure my file names are “nice”, etc etc and its still not working. No image shows up at all…..
Help!
Hello! Excellent plugin, Scott. I’ve added a function to your plugin on my site that allows the category list on the siderbar to display the category pictures instead of the category names. To do this to your own, copy the list_cats() function from template-functions-category.php and paste it into the category-images.php file, renaming it list_cats_with_images(). Call that function in sidebar.php with the same arguments as list_cats() to test if you’ve overridden it correctly. Now, replace these lines in your new list_cats_with_images() function:
$link .= ‘>’;
$link .= apply_filters(’list_cats’, $category->cat_name, $category).’‘;
With these lines:
$link .= ‘>’;
$link .= ‘‘;
That will make images appear instead of the category names! I have made my category images with the text of the category in the picture, so it’s still obvious what category it is. See the sidebar at my website at http://sandstone.brewsters.net for an example of this.
Note that we removed the apply_filters function - I don’t have any idea what this does. Also, I haven’t tested the function with any other arguments other than the WP 1.5.1.3 default, so please post here if you find that this change/addition breaks other argument sets. Thanks again, Scott!
Uh that code was supposed to be:
Replace these lines in your new list_cats_with_images() function:
With these lines:
Holy cow this site keeps ganking the code I’m trying to paste…. probably because it contains php functions and HTML tags - even in a [code] tag.
You can download a .txt file with the required code changes here:
http://sandstone.brewsters.net/Repository/category-images-hack.txt
Scott: Feel free to edit my comments into a single one with the code correctly displayed.
Uhh… I realized that in my post (#89), the css got stripped out of the comment. But if you want to see an example of slashdot-like alignment, look at http://hacktopia.org and look at the source of the page. I’ve actually just changed it to show the images on the left. I think that looks better.
Hi, I just can’t seem to ge htis working… I am noew to all of this (PHP, CMS, etc). but not to CSS & web dev. SO, any hints on what I may be doing wrong?
I have created a directory for wp-content/images/ and placed 2 test images there (both nice-named versions of categories with posts). I enabled the plug-in; I enabled .gif as a selector.
I refresh & all that happens is that the existing category/link dissppears. No graphics. Any hints for a new user?
how can anybody talk about index.php ?
That file is almost empty.
sorry forgot..
How can any one talk about the index.php?
And that the little piece of code should be placed in there?
What a bull!
on wp 1.5.2: i just realised that an old problem has started to reoccur with the cat images. everything works fine, the icons display correctly, but the links to not work in the permalink way.
all that displays is: http://pieceoplastic.com/index.php/category/
but the category slug is missing and that link is hence broken.
is there a way to introduce the “normal” category links here eg.
http://pieceoplastic.com/index.php?cat=1
my bad. its working fine with the latest version of the plugin, i had uploaded the old file…
actually there is a problem when i upgrade to category-image.php 1.2 on my 1.5.2 install: it breaks my feed. where the category image should be
[…] Wow, my first wordpress hack. Thanks has to be given to sandstone for his advice on getting the excellent plug-in “Category image” developed by Scott Reilly to add images to the sidebar instead of the default text. Also, for some good advice on using CSS to give the page the drop-cap look. […]
is anybody else having problems with this?
or maybe even found a solution?
Hi
Great plugin. If I want the category name to display if there is no graphic plug in, where do I make the modification. In the index.php page or in the plug-in.php page. I want the it to be “true”.
$use_name_if_no_image: (optional) if no image for a category is found, should the name be shown instead?; default is ‘false
Here is where I am using it, as an admin-controlled rating system. The stars are your plugin.
http://www.rowby.com
THanks
Rowby
Ah I figured it out and it all displays nicely!
Again great plug-in.
Rowby
http://www.rowby.com
thanks for this plugin, I was looking for something like it all over the web! just a small remark: you’re using an ul element to concatenate one or more icons in one list, but it’s not mentioned in the how-to. not being very experienced with wordpress, I was a bit distressed to find the list bullet. I ended up replacing the list elements with just a span. Looks great with the crystal icons by everaldo!
http://hacktopia.org has exactly what i need. Images auto assigned to a certain category on the left of the textual content in each and every post.
I need a script that puts this code next to the content text (on the frontpage)
where img src is automatically assigned to the category iam posting into.
Could anyone help me out into getting this?
Hi. I am new. I have installed and activated the plugin.
However my index.php does NOT contain any the_category() entries. How do I proceed?
Sorry for the silly question.
[…] Il plugin di cui vi parlo oggi è Category Image(s) di Scott Reilly. Potete scaricarlo da qui. La funzione del plugin in questione è quella di associare una immagine a ciascuna categria del vostro blog. L’installazione è la solita : copiare il file category-images.php nella votra directory dei plugin. E’ poi necessario attivare il plugin. Bisogna poi creare le immagini di categoria. Io ho usato dei piccoli file png. Le immagini vanno messe nella vostra directory wp-content/images/ altrimenti bisognera editare il file del plugin. La cosa importante perchè queste possano essere visualizzate e assegnare ai file delle immagini il cosidetto “nice-name”. Cioè il nome della categoria tutto minuscolo, se questo contiene spazi dovete rimpiazzarli con simbolo_. Per esempio il file di immagine della categoria “Non Categorizzato” si dovrà chiamare “non_categorizzato.png (per esssere chiari). Ultimo passo da compiere è quello di aggiungere il tag “< ?php c2c_the_category_image(’ ‘); ?>” per visualizzare le immagini corrispondenti alle categorie. Io ho inserito il tag nel mio file post.php e l’effetto è quello che vedete in alto. Spero di esservi stato utile. […]
I use the plugin, and it works fine, but it doesnt work, if a category has no posts itself, but some filled subcategories. How do I have to call the c2c_the_category_image function to get an image for “emtpy” categories anyway?
Er, not quite sure WHERE to put the code. My index.php in my root folder is just:
I also checked the template index.php:
Posted in | |‘); ?>
Was about as close as it got. I know I’m missing something stupid and obvious…help me out here ;x
Scratch that, I’ve worked out you stick it in the theme index.php, however no image shows: I have used the nicename for the category (general) and I’ve put it in the right folder (wp-content/images) and placed in the code
But no image appears.
I followed all the instructions exactly. The images will still not post, although if i change the value from false to true to show the names if the images are not found, then that works. Very strange. I’ve tried gifs and pngs. Both should work, but don’t.
I have WP 1.52. I think there needs to be an update…it would be really appreciated!
I’cant find get_category within index.php can anybody point me in the right direction !!!!
Plugins
Yet more work behind the scenes, I’m adding some WordPress Plugins so expect some strange site behaviour. Like zebras and spacehoppers, nothing working and screens of code. Sorry but I apply changes to the live site to see what happens, it’…
I am trying a little different approach on my site http://www.albanywifi.com. Using the plugin at the bottom of each post right next to the category name. It’s working but I have 2 small problems -
1. Can anyone tell me where the
.on the left of the images is coming from?2. Also why are the images on a separate line from the rest of the links at the bottom of the post.
Thanks - any help is appreaciated.
I can post code from any pages needed if that helps.
–r00t
How does it work? Where do I specify the image? I dont see any place in the backend to associate an image with a category. Please help.
Excellent ! Excellent !!! i was looking for this plugin for a very long time and finially found it
I’m not getting the links to come through with the images since WP 2.0. Each image has the link “http://www.clarkburbidge.com/index.php/archives/category/” when there should be the category name after the last “/”. Has anyone else seen this?
Hello, great plugin but i’ve got a problem. I used the new version of wordpress 2.0.1 and activate your plugin, nice-named the images and then want to put the code in my index.php but there’s a problem.
i used the blix-theme but there is no the_category () in it.
How can i install it then.
Greetings eric
I’ve installed the plugin- I’m using wordpress 2 - but I cannot get this to work for me.
I have a category called stories and an image called stories.gif. I am calling the function . I have defined the path in the php file itself.
What am I doing wrong? Any guesses???
thanks so much for your help.
oopps… I forgot to add the code tags, Here is what I am calling within The Loop.
ughhh… I did it again!
I am simply calling c2c_the_category_image(’ ‘) .
Hi,
I’d like to have the post title with the image background.
How do I do that?
[…] Add in the Category Image plug in to this blog. […]
Is there any way to use this in the sidebar? I would like to have it show in posts (next to the category name) and in the sidebar next to the category name. I’m not such a great programmer, but I can usually hack things together through trial and error. Unfortunately, nothing’s worked for me so far. I can’t hard code the icons in the sidebar because the categories are called with PHP.
Thanks
You should really make it more obvious that the edit needs to be done to the template not the actual index.php in the root. Took me a few minutes, err more like 30, to figure it out. I’m a dummy.
Other then that I LOVE IT! Thank you ^_^
this plugin is just awesome! thanks dude!
Just started WPress. Hey, is there a link to an “idiots” guide to using your plug-in? In your installation instructions it ends at copying the php into my root directory. I’m using a custom theme. I just want to hack this in. On which existing php (like style.php etc) do you I use to “call” the function. As you can tell I’m really green and basically have no clue. Any resources would be great. Thanks!
[…] grazie al plugin per WordPress chiamato Category Image(s) ho implementato le immagini per le categorie di post; […]
Thanx for that nice plugin.
[…] Category Image(s) […]
[…] One of the reasons for not posting to my (old) blog for so long was that iBlog became so unreliable that I was afraid another post would further corrupt its database. I finally decided that the only way to save this blog from oblivion was to reactivate it and put it at a place that I trust (Dreamhost) using commonly used software (Wordpress). I thought about using iWeb but couldn’t find anything that would help me converting iBlog entries to iWeb. Instead my search uncovered Agitprop which converted my iBlog entries to the Movable Type import file format which I then imported into my freshly installed Wordpress (Dreamhost’s 1-click installation rocks!). Agitprop refused to convert my image links into proper URLs (the URL field in Option had no effect and the URLs where missing one of the initial “//”) but a quick use of vi fixed that problem. The formatting is still not where I want it to be but this will have to wait. With coffee2code’s plugin I even got to incorporate category images. […]
[…] Je suis entrain d’installer quelques pluggins, pour parfaire le site, avant le launch officiel. Je viens de terminer l’installation du pluggin Category Image, il permet d’avoir une image de la catégorie sur le coin gauche (pour ma part) du post. En attendant, la mise en page, parceque la couleur verte, là, c’est un peu…Je trouve pas la description… […]
Any idea what this plugin would be like? Any demo that you can assist me with?
Thanks!
Hi! I love this plugin (congrats!) and I’d like to know if it will work fine with WordPress 2.1…
Tks!
Hi! same as Lu, i’d like to know if this works with WP 2.x, congratulations!!!!
It does not appear to work with WP 2.1.
I used this with WordPress 1.5, and 2.0. When I upgraded to 2.1, if I enabled the plugin all I got was blank pages, or pages of junk.
I don’t know what’s going on, or how to debug it right now. I’d be happy to help if I knew how.
I did get this to work. Something causes the gzip compression to send unreadable pages with category-images enabled.
Log in as an administrator, go to Options then Reading and uncheck “WordPress should compress (gzip) articles if browsers ask for them.”
That fixed Category Images 1.2 under WordPress 2.1 for me.
[…] Leikin eilen illalla taas koneella ja asensin Category Images -pluginin moottoriin. […]