The code you have there should work based on the following assumptions
- You have set a thumbnail for each post
- You have enabled thumbnails
- You are calling that from within the loop
If you haven’t done any one of those things you should be getting your default image. But that’s just with a cursory glance at your code, and I could be wrong on that.
Related Posts:
- Blog featured images disappeared on my homepage
- How do you add thumbnail support for custom post types?
- Post featured image column on admin post list page
- Disable WordPress’ blogging functionality and disable ‘posts’
- Custom Field in Featured image for A particular post
- media_handle_upload for local files?
- How to add/assign or change featured image in post programmatically?
- How do I use element instead of tags in WordPress post content having webP support?
- How do I convert a mathematical Microsoft Word document to a WordPress blog post?
- widget should display post archive by year and on click also by month
- how to display full post with pagination on home page
- VT-resize image and display it [duplicate]
- blog page showing only first post
- Single Post Gallery Using Shortcode
- Posts Page Featured Image [closed]
- Showing random content / pictures from earlier posts in a sticky post?
- Showing Thumbnail from Previous and Next Posts
- How do I programmatically add an image to a post?
- How to Replace the WordPress Featured Image with a Video?
- How to share same post to multiple site in wordpress?
- Delete Post From Front-End and attachment permanently
- Require a featured image to publish post
- Side by side blog posts that are tied together
- Underscores.me retrieve next / previous post thumbnail in post_nav function
- How to Set Featured image In WordPress without Showing it into Post?
- How to show a full post, not just an excerpt
- How only display all post related to category
- Custom excerpt length filter doesn’t work
- How to get the post’s parent ID?
- Limit Gutenberg blocks available to users to choose from
- How do I find which articles are missing a featured image in The WordPress database?
- How to access featured image?
- Modify WP_Post before processing
- Show featured image next to post-teasers in Genesis Framework?
- Blog Posts not showing title
- Admin Notices don’t display on the admin screen for certain post
- Remove certain post-formats from showing in blog?
- How blog page in WordPress works : blog page retrieve first post ID
- What is the standard featured image size?
- Blog Posts in Custom Menu
- Set featured image as hero image on each page
- Use posts from old db by changing prefix
- Pagination Stops
- Bulk find & replace on WordPress posts/pages (minus image paths)
- How to backup WP blog posts to computer, not new site
- Thumbnails and images in the blog post are not loading
- Customizing a new page used for blog posts with Avada theme
- Blog images not showing on homepage
- post thumbnails error
- Display images of related posts
- Center crop the feature image
- Blog Page doesn’t show summary but full content
- How to generate an HTML link automatically from URL in a users’ post
- Add another feature image box
- Get posts from category from custom query
- My posts page is missing the page title
- Blog Post slider not working
- Multiple Pages – Seperate blogs
- Word /blog/ in slug post, problems in CPT. Solutions?
- How to show category image if no featured image is set?
- Set featured image on creating new post
- Display post on main page with thumbnail
- How to put the WordPress blog into theme
- Why the blog posts is not showing?
- How to get all posts in gallery post format template
- Edit Posts Page but not category specific pages?
- Blog styling in SASS
- Link post to blog from a static page
- Hide first blog post in content and output it in widget
- Thumbnail With Next/Prev Links Not Showing Next Post?
- How can I have the posts from one word press blog show on the presentation page of another word press site
- How do I get thumbnails?
- Page updates appear in Preview but not live version?
- new blog post does not appear in blog after publishing
- Latest news mini images
- Posts don’t appear on the Blog page
- Insert link to my thumbnail images
- Get image paths from RSS feeds
- 2 tick boxes appearing below comments
- thumbnail image path and file path for gallery thumbnail images
- Specific Post Format Image Thumbnail
- long blog post on self hosted wordpress blog not displayed
- Post thumbnail is not shown in wp-admin
- Post thumbnail height problem
- Displaying warning if no featured image has been set – Post Editor
- How enter custom post meta or custom field on box post list archive page?
- WordPress Custom Theme: My site shows the same posts on Page 1 and Page 2 and so on [duplicate]
- Post only showing on homepage when Logged in – direct URL still working
- $attachment->post_title not displaying title
- Posts not showing up on Blog page
- The page that displays Posts on homepage
- How to add a widget area between blog posts in Genesis Framework?
- How to save the same post in multiple blogs?
- Import alt text in set_post_thumbnail
- Need to show birthday of custom post type(Famous people in this case) in elementor. Date of birth set in custom fields
- website images getting corrupt automatically
- Permalink issue with new blog posts > getting 301 redirect
- Changable favicon based on post-featured image
- Blog page shows the whole blog post instead of the excerpt or summary with the feature image only
- Get featured image thumbnail and inserting into custom field on wordpress posts