Viewing 12 replies - 1 through 12 (of 12 total)
  • You could use the Link Manager ?
    Specify that images are to be used for the category (or two), and then when entering the link details, scroll down and specify the image location.
    There may initially be issues with spacing, but a tweak of the css would sort that out easily ??

    I tried something like what was suggested, but it didn’t work.
    Is there any other way to hook an image to a category? Actually what I want to do is, for each of the category links, have only an image and no text.
    Any help would be appreciated.

    Ah! I just found https://www.coffee2code.com/archives/2004/06/27/plugin-category-images/ . I installed it, but I have no idea how to ‘make it work’, and I can’t make heads or tales of the info on that URL. I’ll have to look at it in the morning when I’m rested, I guess.

    Scott Reilly

    (@coffee2code)

    WordPress & Plugin Developer

    How far into the instructions have you gotten, beyond installing the plugin? Do you have the images named a ‘nice-name’ version of the category name (i.e. the category name, but lower-cased, and with all non-alphanumeric characters removed and spaces replaced with underscores… so the category “Fun and Games!” would need a file “fun_and_games.png” (or of some other image extension)).
    Then, in your index.php, replace:
    <?php the_category() ?>
    with something like:
    <?php the_category_image(' '); ?>
    You’ll have to possibly send different arguments depending on if your situation, in terms of image extension and image directory, differs from the default.

    Hi there, and thanks for your help! I ULed the file and installed the plugin via the interface. I do have the images renamed to simple stuff, like “stuff.gif”.
    I replaced the other with <?php the_category_image(‘ ‘); ?>, and nothing happened. It’s like it ignored the code. =/

    Scott Reilly

    (@coffee2code)

    WordPress & Plugin Developer

    What directory did you upload the images to?

    (wordpress directory)/images

    I also tried <?php the_category_image(‘/(wordpress directory)/images/’); ?> , but that didn’t seem to work either.

    Just to make sure, it’s supposed to look like the following, right?
    <div class=”meta”><?php _e(“Filed under:”); ?> <?php the_category() ?> <?php the_category_image() ?> — <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(); ?></div>

    Scott Reilly

    (@coffee2code)

    WordPress & Plugin Developer

    Assuming what you’ve said so far about image type (gif) and location (/wp/images/), (where /wp/ is the absolute location to the root of your blog) then the HTML you posted should be:
    <div class="meta"><?php _e("Filed under:"); ?> <?php the_category() ?> <?php the_category_image(" ", "", "gif", "/wp/images/"); ?> a€?? <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(); ?></div>
    Since you still have <?php the_category() ?> in there, you’ll see both the name of the category and the image. Take it out if you only want the image.

    It’s still not working. =( Now it’s showing “?¢a??a€?”.
    BTW, I changed the info in category-images.php to:
    // In showing the post singularly, then use a larger image, else use a small image
    if ($single) {
    the_category_image(”, ”, ‘gif’, ‘/wp/wp-images/cat-images/’);
    } else {
    the_category_image(”, ”, ‘gif’, ‘/wp/wp-images/cat-images/’);
    }
    …and I’ve ULed the graphics into there too.

    Scott Reilly

    (@coffee2code)

    WordPress & Plugin Developer

    Could you post an URL to your site? I’m still not clear on precisely where you have your images. Assuming you are using the cat-images/ subdirectory from your latest post, this is what you should have in your index.php:
    <div class="meta"><?php _e("Filed under:"); ?>
    <?php if ($single) {
    the_category_image(" ", "", "gif", "/wp/wp-images/cat-images/");
    } else {
    the_category_image(" ", "", "gif", "/wp/wp-images/cat-images/");
    } ?>
    a€?? <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(); ?></div>

    The change you say you did to category-images.php isn’t necessary (and may be problematic). Try all this with an unmodified copy of the plugin.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Using images for category listing’ is closed to new replies.