WordPress.org

Ready to get started?Download WordPress

Forums

Link featured image to the category of the image (1 post)

  1. andresgh
    Member
    Posted 2 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic