Then you’re using it outside of the loop, try this instead:
<?php
if (has_post_thumbnail( get_the_ID() )) {
get_the_post_thumbnail( get_the_ID(), array(80,80) );
} else {
?>
<img src="http://example.org/<?php the_title( get_the_ID() ); ?>" width="80px" height="80px" alt="<?php the_title( get_the_ID() ); ?>">
<?php
} ?>
If you’re not inside of a WP_Query loop, then post-specific functions like has_post_thumbnail()
the_title()
won’t work unless you explicitly pass a the unique-id of a post/page to them.
Related Posts:
- How do I get image url only on the_post_thumbnail
- Get Featured Image via direct sql query
- wp_get_attachment_image_src always returns full-sized image
- Use thumbnail image using url of that image
- Skip posts without a thumbnail in loop
- get_pages – Display child then grandchild pages
- How to replace the_post_thumbnail template tag and show the first inside the post image instead
- Resizing Images to lower Disk Space Using Plugins
- Set (featured) thumbnail for post?
- How to make thumbnail images click into blog posts
- display WP image posts in Bootstrap 4 modal
- Customising the size of images served in Visual Composer elements [closed]
- How to scale up post thumbnails/featured image?
- Get Ancestor featured image
- Upload 3 different featured image sizes to WordPress
- Change size of featured image in Edit Post screen
- Thumbnail and Featured Image With Fixed Sizes?
- the_post_thumbnail ignores size parameter
- Is there a way to change a post’s thumbnail image(s)?
- Confused with the loop and repeating things
- WordPress thumbnail settings change
- Using concatenate with WordPress Thumbnail
- Featured image is not uploading
- how to use the new image size
- Look Through Family Tree and Find Featured Image
- Image still attached to post even after removing it as featured image
- Create custom thumbnail size on existing posts
- thumbnails are getting clipped down, want to resize instead
- Multiple Post thumbnails (at least three)
- How check that there is post thumbnail feature image or not on wordpress?
- Force WordPress to strip/remove EXIF/IPTC metadata when resizing thumbnails
- How to offset thumbnails to the center?
- Secondary Featured Image Function (post_thumbnail)
- Sidebar Thumbs Squished?
- Adding Videos as post-thumbnails (no stills, just the player in a smaller size)
- Getting thubnails for previous posts
- Setting fallback (default) image to featured image block
- Featured Images Not Loading In Blog Archives
- how i can add title to my featured image?
- 2 image size for post
- Needs to add anchor tag in featured image to open in new tab
- Different Featured Images depending on context: loop or single view
- How to both crop (with tool) and resize thumbnails having only a max width constrain?
- Featured image not working, because of custom user role?
- “Medium” size image displayed instead of “thumbnail” in only one post, other posts are fine
- Show last 2 image attachments from posts
- Function to scan for image, attach it to post, set it as featured [duplicate]
- Static news page has for thumbnail the featured image of the first posts
- How to set post thumbnail size?
- Check if parent post is sticky on attachment page?
- get_the_post_thumbnail not working inside wp_get_nav_menu_items hook
- Adding in support thumbnail removes editor
- the_post_thumbnail(‘my_image_size’) always outputs full image
- the post thumbnail, scale
- Why use foreach to get attachment_id if numberposts is equal to 1?
- Query to delete all featured images and remove post meta?
- Retrieving featured image on static blog posts page
- How to allow the user to add an arbitrary amount of post thumbnails
- default post thumbnail and category if there is no thumbnail and category
- Conditional post thumbnail based on logged status and post tag
- How do I add thumbnail to current Prev and next buttons in posts?
- custom class and size for the_post_thumbail
- Check category before displaying featured image
- How to select which thumbnails sizes are displayed in srcset
- How can i find posts with duplicate featured images?
- Does delete_post_thumbnail() actually delete the image?
- Can I prevent get_the_post_thumbnail from falling back to the global post ID?
- How to change thumbnail default size?
- how can I call a posts featured image in any template?
- Custom header image, and content, on Posts Page in twentyeleven with Static Front Page
- Featured Image not shown and getting error “Object of class WP_Error could not be converted to int”
- Resizing old post thumbnail images
- “Use as featured image” not working , “Set Featured Image” hangs. GoDaddy Issue [closed]
- Extract featured image from link mentioned in blog post
- Create an instance of add_image_size
- Enable featured image but not have it show up?
- custom image size not being displayed in loop
- Featured images have disappeared in the Trending section only of my website
- Show thumbnail depending on image width
- Smush Featured image constraining in image file that is being loaded on page
- featured image metabox not moving custom post type
- After migrating media library is not showing thumbnails
- Is it possible to show thumbnails along with recent post from a wordpress blog on static website’s homepage?
- More tag and featured image
- Disable custom image size creation for plugins
- Add Play Icon on thumbnail overlay for video post types
- featured image different style on the list and on single post
- set_post_thumbnail_size has no effect – always 200×300 size is generated
- Adding a class to certain featured images
- query to update post with featured images from array
- Combining Post Thumbnails With Nivo Slider
- WordPress auto picking featured image
- To CSS Style on the image uploaded on a Post under Content Section
- Automatic adding thumbnail to post
- wordpress featured image
- How to stop WordPress from creating native thumbnails?
- How to make the featured image just show up on the blog page?
- Regarding to the performances, should I check if a post has a thumbnail before or after checking if is the front page (or single page, etc.)?
- Display Random Posts with thumbnail instead of just a title of the post
- How to get the real thumbnail size?