Off top of my head here’s two possible solution concepts.
1) Just run the custom loop (I meant to type, query) again and this time use it with only the_post_thumbnail
.
<?php if ($myposts->have_posts() ) : ?>
<div class="image-wrapper e-in">
<?php while ($myposts ->have_posts() ) : $myposts ->the_post(); ?>
<div class="image ">
<!--Post Iamge Will Show Herre According To The Posts-->
<img class="lazy" data-src="https://wordpress.stackexchange.com/questions/316927/<?php the_post_thumbnail_url(); ?>" alt="" />
</div>
<?php endwhile; wp_reset_postdata(); ?>
</div>
<?php endif; ?>
2) Push get_the_post_thumbnail
‘s to a helper array while doing the custom loop. After the custom loop is done, do a foreach
for the helper array to echo thumbnail html outside the loop.
First
$myposts = new WP_Query( $args );
images_html_array = array();
Then inside the loop
images_html_array[] = get_the_post_thumbnail_url();
Then
<div class="image-wrapper e-in">
<?php foreach( $images_html_array as $img_url ) : ?>
<div class="image ">
<!--Post Iamge Will Show Herre According To The Posts-->
<img class="lazy" data-src="https://wordpress.stackexchange.com/questions/316927/<?php echo esc_url( $img_url ); ?>" alt="" />
</div>
<?php endforeach; ?>
</div>
Maybe?
These are just rough code examples and I didn’t test these yet.