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
- Order by DESC, ASC in custom WP_Query
- Exclude or Include category ids in WP_Query
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Query Posts in a Predefined Order
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- How to query for a week using key => value WP_Query argument notation?
- How to use filter hook posts_join for querying taxonomy terms in posts_where?
- How can I style future post?
- List taxonomy terms plus their latest post ordered by post date
- WordPress altering my custom query, How to fix it?
- How to create/modfiy WP_Query to search in post title OR custom field?
- Comparing dates in custom field
- reducing the amount of wp_query calls
- Use post object from first query in second query
- Adding column to wp_posts table or join wp_posts table with another table
- meta_value_num not ordering all items
- Pass $page_id to new WP_Query
- Can I modify a WP_Query instance or clone it with modifications?
- Include posts from some categories while excluding from others
- Show a 404 error page if Public query variable’s value doesn’t exist?
- WP_Query within function within WP_Query
- Multiple Rows in a using wp_query
- How to add tax_query to $args with concatenation
- Change AJAX filter from POST to GET for URL Parameters
- Where is the extra SQL fields coming from?
- How to create a widget like this?
- Does query_posts have an effect on get_the_category?
- Second loop pagination changes URL, not content
- Help with Wp Query
- tax_query in pre_get_posts
- adding pagination to a foreach loop in wordpress
- How to prevent WP_Query from filtering on ‘s’ but keep ‘s’ for other purposes?
- Query on meta values and post title
- Add dynamic search to paginated WP_Query
- Access queried post ID in WP_Query
- Where is the coding error for the unexpected ‘}’ in this if / else choice of loops?
- Order posts by title and custom field value?
- How to show post title in content editor in backend?
- How do I hide submenus from the top menu bar?
- What is the best way to reset a search on a meta_key / meta_value?
- Exclude all tagged posts from WP_Query loop
- Fetch only categorized posts
- Wrap group of wp query posts to parent div by date/year
- Continue loop after $queryObject
- Wrote a WP Cron Plugin and it triggers a fatal error upon activation
- Get the type of an advanced custom field (ACF) in a WP_Query loop [closed]
- Getting Year & Date inside wpdb [duplicate]
- loop through custom post types with meta data
- Using Query In Post Type Archives
- Get posts by meta value except one post [closed]