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
- Custom Field in Featured image for A particular post
- 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 to display full post with pagination on home page
- blog page showing only first post
- Single Post Gallery Using Shortcode
- 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?
- Delete Post From Front-End and attachment permanently
- Side by side blog posts that are tied together
- Underscores.me retrieve next / previous post thumbnail in post_nav function
- How to show a full post, not just an excerpt
- How only display all post related to category
- How to get the post’s parent ID?
- 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
- How blog page in WordPress works : blog page retrieve first post ID
- What is the standard featured image size?
- Why is my Blog Page ID == First Post ID?
- Errors when uploading images in WP 3.5
- Displaying Latest Posts on a Page
- How to make number of blog posts a custom field?
- How can i display gallery shortcode output under Post text
- Display posts from a different website on Genesis Responsive Slider
- WP Bakery Load More Button loads the same posts
- add new post default view
- Show certain posts in a LIST format that members have been granted access to
- why are images not full size?
- Post body text occupying featured image space before it loads
- Posting blog entries in screenplay format
- Get all images in post and comments like Twitter before post title
- Issue where WP Featured Image will not display
- Single.php – Get Current Parent Category
- How to check if single.php has already called the_post_thumbnail function
- Getting only the URL of the post thumbnail
- Remove Featured Image & All Media Uploaded to the Post
- WP move posts to different path
- related author post thumbnail shows post thumbnail
- preg_replace not removed “class”
- how to give multiple post thumbnails to a post
- How to create a page that shows the last 10 posts?
- How to get the latest URL of my blog?
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Post Title to featured Image ALT
- Get featured image on hover of post title [closed]
- How to set a certain Custom Template to a Single Blog Post
- Sidebar on single.php not showing up
- Where is the “Posts”/”Blog” template?
- Retrieve a specific post’s featured image and show on a different page
- How to separate each individual blog post?
- How to display Post title By ID and its Thumb Contents
- Direct some posts to only appear on a specific page
- posts and cms and posts again
- Separate blog and reviews categories
- Create a List of Widgets, where each widget holds three attributes
- Older blog posts not showing up on WordPress
- Post Image Gallery After Content Function messes with other content
- How can I create a ‘sub-blog’ which has its own sidebar on individual posts?
- WordPress empty page! what is wrong with this code?
- Mysql update menu_order problem
- 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
- Customizing a new page used for blog posts with Avada theme
- post thumbnails error
- Center crop the feature image
- Blog Page doesn’t show summary but full content
- 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
- 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 get all posts in gallery post format template
- Edit Posts Page but not category specific pages?
- Link post to blog from a static page
- Thumbnail With Next/Prev Links Not Showing Next Post?
- How do I get thumbnails?
- Latest news mini images
- Get image paths from RSS feeds
- 2 tick boxes appearing below comments
- long blog post on self hosted wordpress blog not displayed
- Post thumbnail height problem
- Displaying warning if no featured image has been set – Post Editor
- WordPress Custom Theme: My site shows the same posts on Page 1 and Page 2 and so on [duplicate]
- $attachment->post_title not displaying title
- The page that displays Posts on homepage
- How to add a widget area between blog posts in Genesis Framework?
- 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