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 id="latest-posts-pictures"> <img src=""width="190px" height="190px" alt="latest-posts-pictures"> </div>
    <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>

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:

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

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

<?php endwhile; ?>

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


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: