• Resolved Jonas_

    (@jonas_)


    Hello,

    i’m listing all my categories in a 4*4 grid, but what i want is to have a image to the left of it.. is this possible? if so where should i start?
    because i currently use <?php wp_list_categories('orderby=count&title_li='); ?> but i don’t see any parameters that can do this or am i wrong??

    thanks in advance!

Viewing 11 replies - 1 through 11 (of 11 total)
  • You could try adding images via CSS.

    Thread Starter Jonas_

    (@jonas_)

    i currently have

    <?php
    foreach(get_categories() as $category) {
        echo '<img src="https://.../images/' . $category->cat_name . '.jpg" alt="' . $category->cat_name . '" />';
    }
    ?>

    but this only shows my images.. i think im doing it right or not?
    i now need to echo the cat_name with a link to it and put them in a list and then it should work fine ??

    BUT can’t i just add this code so its added to the default template?
    i tried copying the code from general-template.php and paste it in functions.php and adding the image code to it and then i did a add_action( 'wp_list_categories', 'wp_list_categories_test' );

    but it didn’t work.. in fact my page didn’t display anymore ??
    although i think this is THE WAY TO GO?

    Thread Starter Jonas_

    (@jonas_)

    can you just copy the code from general-template.php into functions.php? or does this gives errors without changing anything?

    Thread Starter Jonas_

    (@jonas_)

    note: i meant category-template.php instead of general-template.php

    No. Don’t mess with core code.

    Thread Starter Jonas_

    (@jonas_)

    I’m not really messing with the core code… i’m copying it so i can create my own function to override the default one… but i’ve to change things there but i’m not sure what..

    You can’t just copy code code into your theme (amended or otherwise). Unless you really, really, know what you’re doing, you risk bring your whole site down with a fatal error. Far better to continue working with your original code and develop your own custom category listing function.

    Thread Starter Jonas_

    (@jonas_)

    okay, but i thought because its almost the same as the original, basically only adding the image, i could c&p it but not ??

    I’ll try it from scratch then

    Thread Starter Jonas_

    (@jonas_)

    seriously i didn’t know it was so easy to do this lol ??
    wordpress is a very nice cms ??

    Glad to hear you managed to get it sorted. Sounds like a whole new horizon just opened up too. ??

    Thread Starter Jonas_

    (@jonas_)

    indeed ?? i’m creating everything from scratch and you learn very fast here ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Adding thumbnail image to each category’ is closed to new replies.