How to show featured image when mouse hover a link?

Discussion in 'WordPress' started by Divvy, Jan 23, 2016.

  1. #1
    Hello guys,

    Maybe someone can help me...

    Lets say that I have a link in my site:
    <a href="url">text</a>
    Code (markup):
    How can I show the post featured image when I put the mouse hover the link?
    Does anyone know any good method or plugin to do that?

    Thank you guys! :)
     
    Divvy, Jan 23, 2016 IP
  2. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #2
    I have found this method and is almost done:
    http://www.dynamicdrive.com/style/csslibrary/item/css-popup-image-viewer/

    The only issue that I have now is to show a custom post type feature image in my single.php.

    I am trying this code:
    <?php the_post_thumbnail('freeGallery', array('class' => 'imgthumb')); ?>
    PHP:
    But without success...
    It shows the post (single.php) featured image and not the custom post (freeGallery) featured image.

    What Im doing wrong?
    Can please someone help me? :)

    Thanks!!
     
    Divvy, Jan 23, 2016 IP
  3. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #3
    This is my code, but isn't working... Is only showing the post featured image and not the custom post type featured image.
    Can someone tell me what I'm doing wrong?

    <?php
    $loop = new WP_Query(array('post_type' => 'freeGallery', 'post_status' => 'publish'));
    ?>
    <td><div class="gallerycontainer">
    <a class="bestthumbnail" target="_blank" title="<?php echo $post_title; ?>" href="<?php echo get_post_meta($ID,'mr_freeGalleryUrl',true); ?>" rel="nofollow"><?php $title = $post_title; if (strlen($title) > 85){ echo substr($title,0,85).'...';}else { echo $title;}?><span><?php the_post_thumbnail('freeGallery', array('class' => 'imgthumb')); ?></span></a></div></td>
    PHP:
    Thanks :)
     
    Last edited: Jan 24, 2016
    Divvy, Jan 24, 2016 IP