• Resolved Bittabola

    (@bittabola)


    Hi, guys!

    The following code generates a box with the thumbnail of a corresponding page:

    <div class="feature-box">
                <?php 
                $args = array(
                    'post_type'=>'page',
                    'page_id'=>48,
                );
                $query = new WP_Query($args);
                if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); 
                    if (has_post_thumbnail()) :
                        the_post_thumbnail('home-page-thumb');
                    endif;
                ?>
                <?php 
                endwhile; endif;
                wp_reset_query();?>       
            </div>

    I am looking to add a link to this box so the whole box becomes clickable. Please help with adding a link.

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    if (has_post_thumbnail()) :
       $link = get_permalink( get_the_ID());
       echo "<a href=\"$link\">";
       the_post_thumbnail('home-page-thumb');
       echo '</a>';
    endif;
    Thread Starter Bittabola

    (@bittabola)

    Thanks a lot! Worked like a charm

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding a permalink to the Loop’ is closed to new replies.