badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

Service icon link to page

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #21082
    m.l.cap123
    Participant

    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.

    #21153

    Hi 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 code

    if ( 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!

    #21178
    m.l.cap123
    Participant

    Thanks. 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.

    #21242
    m.l.cap123
    Participant

    I 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 –>

    #21268

    Ok that’s great m.l.cap123

    Thank you!

    #21576
    Felipe
    Participant

    Please, post de code again? I need same code for link the icon service, but is broken.

    #21608

    Hi felipe1,
    This services widgets is displayed from the theme folder -> inc -> widgets -> interface_widgets.php line no 278 and you will fine this code

    if ( 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!

    #21632
    Felipe
    Participant

    Hello. Thank you for the help, it was perfect! 🙂

    #21654

    Ok that’s great felipe1

    Thank you!

    #21655

    Ok that’s great felipe1

    Thank you!

    #23957
    nklee
    Participant

    Great this fix still works!

    #23985

    You welcome nklee

    Thank you!

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.