• I was able to create a custom image for each category on my site here: http://www.pinkfloydonline.com – (Notice the purple arrows that say “Pink Floyd News” and “Pink Floyd Video of the Week”.

    Now I am trying to get it to link to it’s category, but can’t seem to get it to work.

    Here is the code I used for the custom image:

    <?php
    foreach((get_the_category()) as $category) {
        echo '<img src="http://pinkfloydonline.com/images/' . $category->cat_ID . '.png" alt="' . $category->cat_name . '" title="' . $category->cat_name . '" />';
    }
    ?>

    I looked at the codex and tried adding <?php get_category_link( $category_id ); ?> like this:

    <?php
    foreach((get_the_category()) as $category) {
        echo '<a href="<?php get_category_link( $category_id ); ?>"><img src="http://pinkfloydonline.com/images/' . $category->cat_ID . '.png" alt="' . $category->cat_name . '" title="' . $category->cat_name . '" /></a>';
    }
    ?>

    But it didn’t work.

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Floyd3

    (@floyd3)

    I know “php_get_the_category” makes a link to the category, but how can I get that custom image to link to the category?

    Hi,
    If php_get_the_category returns the correct link then your code should work… when you say it didn’t work what do you mean?? the image has no link? is there any javascript that takes over the click event? it creates a link to a 404/other page?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Category Image – Got that to work, but can't get it to link to it's URL’ is closed to new replies.