Instead of using the tag outside, you can echo the output inside the post loop.
And no need to add the $post ->ID because WordPress will automatically pick up the thumbnail with the wp_get_attachment_url() function.
Related Posts:
- Query posts only with featured image
- Different ‘posts_per_page’ setting for first, and rest of the paginated pages?
- In loop: posts have thumbnail AND other variables
- How to adjust found_posts so that it accounts for offset and pagination
- WP Query with offset breaks wp_pagenavi or any pagination
- Exclude first 5 posts of specific categories in the main loop
- Custom query, works, but I get a “Notice: Undefined offset: 0…”
- post thumb nail
- Trying to check and see if a post has a featured image outside of the main loop
- Query sticky posts with thumbnails
- Retrieve featured image (thumbnail) url from multiple posts with one query
- Get image of latest post from taxonomies/categories
- Multiple instances of Featured Image Query
- post thumbnail not showing up with shortcode
- How WordPress attaches its Featured Images with posts?
- Offset Page Loops and Pagination
- How to use offset in WP_Query
- getting post thumbnail within loop causes an error
- How can I fix: “Notice: Undefined offset: 0”?
- WP_Query, pre_get_posts and offset
- WP_Query condition affects posts_per_page count
- Site not getting correct featured image from my query
- Retrieve posts using thumbnail id as meta key
- WP Query – Post Thumbnail
- WP_Query with offset and ‘orderby’ => ‘rand’, offset not working
- How do I rewrite this loop as a new WP_Query style-loop?
- How can I check for a thumbnail in WordPress?
- WP_Query arguments order
- how would i change post->ID to work correctly when querying pages?
- How to display the featured image for each post?
- Query posts only without featured image
- WP_Query – Adding “offset” posts to the end of the loop
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Apply query arguments after the nth post
- AJAX Breaking Offset Argument In WP Query
- Page navigation doesn’t seem to work when I add offset?
- WP_Query offset is returning post from prevois loop
- the_post_thumbnail do 2 queries. How to optimize
- Offset WP_Query by negative 1
- Featured images loop for Orbit Slider
- how to put thumbnail below category’s title?
- setting offset to category number in archive page
- WP_Query how to add a thumbnail to the first post from the last 5 posts?
- Using something else instead of using 9 wp_query
- Trying to use “Medium” featured image for custom post type on home page
- wp_get_attachment_image not to get the post_thumbnaill
- WordPress WP_Query offset parameter not working with search parameter
- Featured image not showing on page
- Display First posts without the default featured image
- Display only posts with thumbnails
- Multiple WP_Query with pagination shows Page/2 content on the remaining pages
- What is the best way to offset previous posts on the same page?
- WP_Query offset returning duplicate posts from previous loops with AJAX
- When should you use WP_Query vs query_posts() vs get_posts()?
- When to use WP_query(), query_posts() and pre_get_posts
- WP_Query by just the id?
- Meta_query compare operator explanation
- WP_Query with “post_title LIKE ‘something%'”?
- wp query to get child pages of current page
- How to get an array of post data from wp_query result?
- How to get post id of static front page?
- meta_query with meta values as serialize arrays
- How to only display posts whose meta_value field is not empty?
- Get post ids from WP_Query?
- Pagination when using wp_query?
- Exclude post ID from wp_query
- How to print the excuted sql right after its execution
- How to extend WP_Query to include custom table in query?
- How to store and receive variables in WP sessions?
- Should I use Pre Get Posts or WP_Query
- How can i retrieve default post per page value? from settings->reading. And total number of posts?
- Nested meta_query with multiple relation keys
- Is it necessary to use wp_reset_query() in a WP_Query call?
- Can I force WP_Query to return no results?
- Can wp_query return posts meta in a single request?
- Using pre_get_posts with WP_Query
- Find out total number of pages in global query on archive page?
- WP_Query + random
- Resetting post data to previous loop in nested loops
- order by numeric value for meta value
- numberposts? showposts? posts_per_page?
- $GLOBALS[‘wp_the_query’] vs global $wp_query
- Broken? WP_Query and “attachment” as a post type
- Some doubts about how the main query and the custom query works in this custom theme?
- Order by multiple meta key and meta value [closed]
- Post_count only shows the number of results per page
- Page template query with WP_Query
- meta_query ‘compare’ => ‘IN’ not working
- Wp get all the sub pages of the parent using wp query
- What is appropriate flow for custom data from URL in WP_Query?
- How to display page content in a page template?
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- How to merge two queries together
- Posts with at least 3 tags of a list of tags
- Get post count of current loop when using multiple queries on one page
- why ignore_sticky_posts in sticky post query
- Wp_redirect and sending variables
- Multiple relationship for multiple tax_query in WP_Query
- How do I get posts that have a thumbnail in WP_Query?
- Multiple WP_Query loops with Pagination