Ready to get started?Download WordPress


Using images for category listing (13 posts)

  1. KyleGM
    Posted 9 years ago #

    Is there any way to list the categories -list_cats()- using images?
    For example:

  2. Mark (podz)
    Support Maven
    Posted 9 years ago #

    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 :)

  3. Eris
    Posted 9 years ago #

    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.

  4. Eris
    Posted 9 years ago #

    Ah! I just found http://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.

  5. 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.

  6. Eris
    Posted 9 years ago #

    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. =/

  7. What directory did you upload the images to?

  8. Eris
    Posted 9 years ago #

    (wordpress directory)/images

  9. Eris
    Posted 9 years ago #

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

  10. Eris
    Posted 9 years ago #

    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>

  11. 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/"); ?> � <?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.

  12. Eris
    Posted 9 years ago #

    It's still not working. =( Now it's showing "�".
    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.

  13. 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/");
    } ?>
    � <?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.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.