Tagged: Link added in Icons
- This topic has 11 replies, 4 voices, and was last updated 9 years, 8 months ago by Theme Horse Support Team.
-
AuthorPosts
-
January 24, 2015 at 12:32 pm #21082m.l.cap123Participant
Hi. I’m working on a site and the client wants the service icons to link to their respective pages. The service icon widget displays the featured image. I’ve tried a few options already including adding this code to the functions.php:
<?php
add_filter( ‘post_thumbnail_html’, ‘add_post_link_to_featured_image’ );function add_post_link_to_featured_image( $html, $post_id, $post_image_id )
{$html = ‘‘ . $html . ‘‘;
return $html;}
?>The issue is on the homepage at homesmartclean.com. I would also be find the with service icon titles linking to their pages. I removed the “read more” by using display:none. Any ideas? Thanks.
January 26, 2015 at 5:22 am #21153Theme Horse Support TeamKeymasterHi m.l.cap123,
This services widgets is displayed from the theme folder -> inc -> widgets -> interface_widgets.php line no 278 and you will fine this codeif ( has_post_thumbnail() ) { echo'<div class="service-icon">'.get_the_post_thumbnail( $post->ID, 'icon' ).'</div>'; }
You need to add anchor tag to make it clickable.
Thank you!
January 26, 2015 at 12:06 pm #21178m.l.cap123ParticipantThanks. I’m trying to add an anchor which I think looks like this:
‘<a href=”<?php
the_permalink(); ?>” title=””><?php echo $page_title; ?>‘
I’m adding it here:
if ( has_post_thumbnail() ) {
echo'<div class=”service-icon”>’.get_the_post_thumbnail( $post->ID,
‘icon’ ).”<a href=”<?php
the_permalink(); ?>” title=””><?php echo $page_title; ?>‘</div>’;
}
?>It’s breaking the site so I loaded the original file. Can you be more specific about where exactly I need to add the code and what exactly the code should be? Thanks.
January 27, 2015 at 8:40 pm #21242m.l.cap123ParticipantI figured it out. Here’s the original code:
<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 –>
And here’s the new code:
<div class=”service-item clearfix”>
<?php
if ( has_post_thumbnail() ) {
echo ‘ID ) . ‘” title=” ” ‘ . esc_attr($thumbnail->post_title ) . ‘”>’;
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 –>January 28, 2015 at 5:34 am #21268Theme Horse Support TeamKeymasterOk that’s great m.l.cap123
Thank you!
February 4, 2015 at 11:31 am #21576FelipeParticipantPlease, post de code again? I need same code for link the icon service, but is broken.
February 5, 2015 at 5:52 am #21608Theme Horse Support TeamKeymasterHi felipe1,
This services widgets is displayed from the theme folder -> inc -> widgets -> interface_widgets.php line no 278 and you will fine this codeif ( has_post_thumbnail() ) { echo'<div class="service-icon">'.get_the_post_thumbnail( $post->ID, 'icon' ).'</div>'; }
and replace it with this below code
if ( has_post_thumbnail() ) { echo '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( $post->post_title ) . '">'; echo'<div class="service-icon">'.get_the_post_thumbnail( $post->ID, 'icon' ).'</div>'; echo '</a>'; }
Before making any changes first make child theme and then only customize the code. If you add this code directly inside the interface_widgets.php file then it will work but while updating to our new version all your customisation code will be lost. If you didn’t make any changes then you need to make the same changes for each and every time.
Thank you!
February 5, 2015 at 6:34 pm #21632FelipeParticipantHello. Thank you for the help, it was perfect! 🙂
February 6, 2015 at 6:40 am #21654Theme Horse Support TeamKeymasterOk that’s great felipe1
Thank you!
February 6, 2015 at 6:40 am #21655Theme Horse Support TeamKeymasterOk that’s great felipe1
Thank you!
April 12, 2015 at 3:29 am #23957nkleeParticipantGreat this fix still works!
April 13, 2015 at 4:38 am #23985Theme Horse Support TeamKeymasterYou welcome nklee
Thank you!
-
AuthorPosts
- You must be logged in to reply to this topic.