I could be mistaken, but I don’t think $post->post_id
works to retrieve the post’s ID. I believe you want $post->ID
. So that was probably your issue to begin with, though without seeing your $attr
array, it’s hard to say. Here’s a reference for $post
‘s properties. In this case, get_the_post_thumbnail
is the more appropriate function.
In your answer you posted for yourself, you’re using the_post_thumbnail
incorrectly. First off, you don’t need to echo it; the_post_thumbnail
will output the thumbnail. Side note: Any function in WordPress
that starts with the_
is almost always going to output something automatically. Second, You don’t need to pass it $post->ID
(again, using the wrong property). Third, the first property of the_post_thumbnail
is the size, e.g. “thumbnail”.
Related Posts:
- How do I regenerate thumbnails?
- Add Title Attribute to WordPress Image the_post_thumbnail
- Display Category Thumbnail and links in Woo commerce
- Replacing Gutenberg Featured Image control?
- oEmbed, thumbnails and wordpress
- the_post_thumbnail scaling not hard cropping
- Add Image Dimensions to Media Library Tab on Media Upoader
- Featured Image Inherited from Parent Page
- Change wording of default thumbnail metabox
- Specific featured image for each category
- how to pull images with no add_theme_support(‘post_thumbnails’)
- Can WordPress crop only the post thumbnails?
- Query the post which have a thumbnail
- How to show a featured image as current?
- How can I get a different image size, if all I have is the link?
- How to get custom image sizes into media uploader dropdown?
- Show current page featured image in sidebar
- How do I get a random image from subset of images in media gallery?
- Importing featured image to posts, duplicates the image
- PDF Image in content
- How do I set a featured image (thumbnail) by image URL when using wp_insert_post()?
- Why does the Hard Crop option Scale?
- Use post thumbnail as div background
- How do I set the default “feature image” size?
- Featured Image missing in WordPress 3.2 Admin
- Change post thumbnail using front end post edit form
- Featured image thumbnail sometimes in content, sometimes changes header images
- Function to replace the url of featured images in the wordpress database?
- has_post_thumbnail gives always TRUE
- Displaying wordpress image size as array used for page builder
- Get post thumbnail from subpages with a foreach loop
- Setting a default placeholder image WITHOUT link
- If I Regenerate Thumbnails, would WordPress delete the existing Thumbnails and replace them with ‘new copies’?
- How to inject attributes into get_the_post_thumbnail?
- how to use first post image as thumbnail on wordpress
- Make the first image the post thumbnail without setting it as the featured image
- MultiPostThumbnails for Custom Post Type
- set a chosen image-file-input as a featured image from wp frontend
- Aligning the thumbnail image
- WordPress Featured Image function recreate
- How do get post thumbnail into plugin?
- Using Featured Image as Hero Background
- Default Featured Image from Post content
- upload or auto setup feature photo by user avatar
- How to replace featured image upload option with the post media image option
- How to create resized versions of images added with wp_insert_attachment
- Can I insert the feature image inside the content, after any paragraph?
- Set Post Thumbnails in Percents
- WordPress returns old thumbnail size after changing media settings
- get_the_post_thumbnail() returns nothing?
- How to bring files from the upload directory to the media gallery?
- Image with large file size not cropping
- What can I do if I set a gif as featured image? no thumbnail when i share on facebook
- Can’t get post thumbnail to display in foreach loop
- Child Category Image
- post thumbnail: increase dimension if smaller than… Possible?
- Displaying caption with featured image
- add_theme_support post-thumbnails not working
- Trying to show WordPress category query result as background image
- How risize a thumbnail?
- custom thumbnail image size not working
- Comparison Operators not working for conditional author post thumbnails
- Assign SQL ‘post_thumbnail’ column as featured image
- Default thumb – how to set it
- How to get featured image thumbnail to open larger version in attachment page?
- How to update custom image sizes?
- My Gallery Photos are showing in the post’s excerpts
- featured images twenty eleven theme
- Picture inserted in the post not showing in “Gallery”
- featured image is not showing
- How to change the format of thumbnails into wordpress theme?
- How to calculate the sum of all featured thumbnail height on WordPress?
- How to create thumbnails programmatically?
- Thumbnails regenerate wp_generate_attachment_metadata
- Missing image size
- Usage of add_image_size (for featured image)
- Featured image: Dynamic image sizes when enlarged with javascript
- Add space under featured image in singel post
- Smaller Size for featured images
- Featured image doesn’t appear in Blog index
- Remove Featured Image based on Date
- How to show only 2nd featured img on home/blog
- Echo recent posts each with its own respective featured image
- How to get post thumbnail to be equal to set media size
- Add notice to add image popup
- Mass/Bulk assign featured images to posts
- Displaying All Parent Pages as Featured Images
- setting featured image is not working while running script in background, works when running that script from browser
- WordPress save thumbnail but don’t show it [closed]
- How to modify responsive images in post thumbnails
- get_the_post_thumbnail() – Invalid argument supplied for foreach() in /wp-includes/post-thumbnail-template.php on line 64
- Different thumbnail size than actual picture in post
- How to get the featured image inside of a single-.php template?
- Where is the template from the_post_thumbnail()?
- Get Post Thumbnail Outside of Loop
- Theme:Twenty Fourteen, How to remove featured image on single post page for particular category
- Strange image artifact on font-page thumbnail image
- Delete post media except featured image
- Images thumbnail not cropping square
- wp media regenerate says “no regeneration needed” whe that’s no the case