How to show the picture of a post when it’s link is hovered in WordPress

There is a part in my website where the last 6 posts are reviewed and this is the HTML code for it:

<div class="latest-posts">
      <div id="latest-posts-title">
    <p>My Website's latest posts</p>
  </div>
      <div id="latest-posts-pictures"> <img src=""width="190px" height="190px" alt="latest-posts-pictures"> </div>
      <ul>
    <li><a href="#">Post1</a></li>
    <li><a href="#">Post2</a></li>
    <li><a href="#">Post3</a></li>
    <li><a href="#">Post4</a></li>
    <li><a href="#">Post5</a></li>
    <li><a href="#">Post6</a></li>
  </ul>

I want to add a feature to make the user able to see the post’s picture when he/she hovers the post’s link in the code above.

I’ve used this PHP code and it works well:

<ul>
<?php
$my_query = new WP_Query('showposts=6&cat=my_category');
while ($my_query->have_posts()):
$my_query->the_post();
$do_not_duplicate = $post->ID;?>

<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>

<?php endwhile; ?>
</ul>

But this code does not contain the picture part that I want.
Do you know how can I make this feature available for my users?

Please note that it is not important for me to use PHP or JavaScript, all I
want is to make it possible for the user to see the post’s picture
when he hovers its link.

Read more here: How to show the picture of a post when it’s link is hovered in WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *