• Resolved kdmahesh1788

    (@kdmahesh1788)


    I want to add hyperlink to my featured thumbnails on the homepage. This is my homepage: https://www.optionsinfinite.com/
    From WordPress guide i found this code:

    <?php if ( has_post_thumbnail() ) : ?>
    	<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
    	<?php the_post_thumbnail(); ?>
    	</a>
    <?php endif; ?>

    But when I inserted this code in my file, thumbnails became hyperlinked but it changed the arrangement. So, how to add above code in proper manner in the file to make make thumbnails hyperlinked without changing the arrangement.

    Please find the code from my file:

    <div class="<?php echo $service_class; ?>">
        <div class="service-item clearfix">
          <?php
    							if ( has_post_thumbnail() ) {
    								echo'<div class="service-icon">'.get_the_post_thumbnail( $post->ID, 'icon' ).'</div>';
    							}
    							?>
          <h3 class="service-title"><?php echo $page_title; ?></h3>
        </div>
        <!-- .service-item -->
        <article>
          <?php the_excerpt(); ?>
        </article>
        <a class="more-link" title="<?php the_title_attribute(); ?>" href="<?php the_permalink(); ?>">
        <?php _e( 'Read more','interface' ); ?>
        </a> </div>
      <!-- .one-fourth -->
      <?php $j++; ?>
      <?php endwhile;
    		 		// Reset Post Data
    	 			wp_reset_query();
    	 			?>
    </div>
    <!-- .column -->
    <?php echo $after_widget;
     		}
     	}
Viewing 2 replies - 1 through 2 (of 2 total)
  • try to integrate the suggested code into this section:

    <?php
    if ( has_post_thumbnail() ) {
    	echo'<div class="service-icon">'.get_the_post_thumbnail( $post->ID, 'icon' ).'</div>';
    }
    ?>

    example (untested):

    <?php
    if ( has_post_thumbnail() ) { ?>
    	<div class="service-icon"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
    <?php echo get_the_post_thumbnail( $post->ID, 'icon' ); ?></a></div>
    <?php }
    ?>
    Thread Starter kdmahesh1788

    (@kdmahesh1788)

    You rock man! It is resolved, now my icons have become clickable. Thank you so much!!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to add hyperlink to the Featured Thumbnails’ is closed to new replies.