Forums

[resolved] query_post adding post link to thumbnail (3 posts)

  1. wickedpenguin
    Member
    Posted 1 year ago #

    Hi All,

    I am currently using the below query_post statement to pull thumbnails from the previous 9 posts.

    Currently the thumbnails aren't click able, and I wanted to link them to their related post.

    Anyone?

    [please use the 'code' button to mark the code]

    <div id="homebox3">
    
    		<?php
                     $lastposts = get_posts('numberposts=9');
                     foreach($lastposts as $post) :
                        setup_postdata($post);
                     ?>
                      <?php the_post_thumbnail(array(50,50)); ?>
                     <?php endforeach; ?>
    
    </div><!-- #homebox3 -->
  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    try to change from:

    <?php the_post_thumbnail(array(50,50)); ?>

    to:
    <a href="<?php echo get_permalink($post->ID); ?>"><?php the_post_thumbnail(array(50,50)); ?></a>
    `

    http://www.w3schools.com/html/html_links.asp

  3. wickedpenguin
    Member
    Posted 1 year ago #

    your a legend, thanks mate. Just what I was after.

    So easy when you know how. :)

Topic Closed

This topic has been closed to new replies.

About this Topic