WordPress.org

Support

Support » How-To and Troubleshooting » Link featured image to the category of the image

Link featured image to the category of the image

  • I want to make a featured image of a post link to the category of a post not to the link it self. Is there anyway I can do that?
    Currently I have tried Im trying to using

    <?php if ( has_post_thumbnail()) : ?>
                               <a href="<?php $url = get_category_link($categories[1]->cat_ID); ?>" title="<?php the_title_attribute(); ?>" >
                               <?php the_post_thumbnail(); ?>
                               </a>
                         <?php endif; ?>

    but this links the images to the category template were more post with different categories are displayed.
    For example:
    category_template_a has post of categories d,g & h and right now the link takes you to category_template_a and I want it to link to category_template_d,g or h depending on what post featured image is clicked on.
    Any idea on how I can do this?

  • The topic ‘Link featured image to the category of the image’ is closed to new replies.
Skip to toolbar