the_post_thumbnail()
will show the thumbnail of the current post in the Loop. Since you are using a custom foreach() loop instead of starting your own WordPress Loop, you can use this instead to specify which post you want:
<?php echo get_the_post_thumbnail( $recent_post->ID ); ?>
Related Posts:
- Retrieve each widget separately from a sidebar
- How can i use the same template file with a widget and category loop?
- Including post thumbnail url in loop’s post object to reduce number of queries
- Problem getting current post tags to show in a widget
- is_active-sidebar loop
- WP Loop. If featured image is a panorama (3:1 ratio) execute some code
- Contact information footer
- New loop vs widget
- Closing the loop…featured image variable based on post id
- WordPress get post thumbnail url
- How to output thumbnail twice in a loop
- Default featured image set as background image [closed]
- How can I access a post’s feature image outside the loop?
- How to check all items in a loop have post thumbnail?
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- wp_get_attachment_url not fetching URL?
- How to display a loop of custom post types in columns
- Thumbnail of the latest posts page
- Need some help with “the_widget()” function
- Showing related posts (custom post type) outside of the loop
- Pages with a loop (index, archive) are loading the first image as post_thumbnail
- Display Featured Image
- Place the Featured image on a post, before the first via code
- How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()? [closed]
- How to get Author ID outside the loop
- remove tags from the_content
- Why do themes rely on “The Loop”?
- How to place comments_template(); outside the loop?
- Display thumbnail only on the very first post in the loop?
- Endless loop with wp_insert_post and wp_update_post
- Hook into the loop via a plugin, and output something after every X post?
- Two custom loops, pagination, offset
- Access to Media Library
- Getting two wp_link_pages output
- post loop causes wp_users and wp_usermeta DB queries for each users
- Ajax loop refresh on click
- Run The Loop over array of post objects
- the_excerpt(), get_the_excerpt() and the_content() all killing “the Loop”
- Enable infinite scroll on single.php [closed]
- Is get_posts() more efficient than The Loop?
- loop through all posts memory error
- Does get_template_part pull data once in a loop?
- How to retrieve “sticky” post outside the “loop”?
- Using get_the_excerpt() Before The Loop
- code suddenly appearing from my tempate second loop
- Get post/page data outside the loop
- How to go about combining dropdowns / filter queries?
- woocommerce get_price_html not pulling in correct price
- Trouble Formatting DateTime
- Order archive results by post id in custom taxonomy template
- How to fix pagination for custom loops?
- pre_get_posts for two loops on same page
- How to display posts by vote count and if no value continue with latest posts with no votes?
- Sort results by groups of numbers and letters
- Modify the main loop to display current month / year
- Display post list with different styles
- Problem with displaying HTML content after in_array [closed]
- post thumbnail, conditions, else wont work
- Loop for sticky posts
- Get author_id in wordpress
- Single.php different behaviour from admin to non-admin
- Array ids post to function have_post
- Can’t access PHP array inside script localization from javascript
- ACF – add a group inside a repeater [closed]
- Give each posts in a loop a number in sequence
- Get post offset/posts page offset in single post page (outside the loop)
- First article : single column; Other articles : 2 columns
- get_comments with post_status ‘public’ retrieves NULL result
- Content Visibility for WordPress is not working (Drafts, public etc.)
- Generating a perfect loop
- add offset to archive page
- Category ID returns as ‘0’?
- make get_post work in the loop
- How to display 3 post per slide
- For Each +1 WordPress Loop
- Loops for cat links not looping for wordpress site
- Skip 5 latest post while paging?
- WordPress: query pages except remove one page
- get_post_meta printing empty fields, but it shouldn’t be
- Is it possible to set archive.php instead of index.php to display blog?
- How to read taxonomy in loop?
- get the value for ALT is we check to see if an actual ALT value is set, if not we use the caption and if no caption is set we use the title
- how to add 4 post in one carousel slide
- Exclude Posts Using Meta Query and User Meta
- Is “the loop” a template tag?
- Show a list of user posts in the user admin page
- WordPress with woocommerce custom query
- Page gets displayed in post field
- Active class for my flexslider in WordPress
- How to display thumbnail if post is assigned one otherwise not
- get_template_part() to render single page Theme
- Can’t see custom field after the Loop [closed]
- Same Loop on Multiple Pages
- The Loop for my theme with static front page is not working
- WordPress loop: Display if posts exist
- strange parse error when including a loop template within another template
- Previous Posts Link and Next Posts Link Show All The Same Articles?
- Showing ads after posts in home page
- Undefined variable: woocommerce_loop [closed]
- Prevent duplicating specific column from database table