The ID of the featured image is stored under the meta key _thumbnail_id
, so we can do a query for a single post that has this key:
$args = array(
'posts_per_page' => 1,
'meta_key' => '_thumbnail_id',
'cat' => $cat_id
);
$latest_thumb = new WP_Query( $args );
if( $latest_thumb->have_posts() )
return get_the_post_thumbnail( $latest_thumb->post->ID );
Related Posts:
- How to disable WordPress from creating thumbnails?
- How to Dynamically Resize WordPress Image On-The-Fly (custom field/theme option)
- Display Category Thumbnail and links in Woo commerce
- media_sideload_image generates blank?
- Post thumbnail outside the loop
- How do I add the featured image to the_content after the first paragraph?
- Showing a placeholder/default img, if no featured image is set
- Re-order media links?
- How to show featured image CAPTION only if it exist
- Add Image Dimensions to Media Library Tab on Media Upoader
- Featured image for news page
- Fallback default image when there is no featured image
- Adding schema itemprop image to the_post_thumbnail with filters
- How to get custom image sizes into media uploader dropdown?
- wordpress responsive image srcset not working
- Possible to swap in a placeholder image globally for the_post_thumbnail_url if one doesn’t exist?
- How do I get a random image from subset of images in media gallery?
- Why are extra 92 pixel square thumbnails created?
- wp-cli regenerate media is not working for custom sizes
- Remove dimensions from filename featured image
- PDF Image in content
- create new post using rest API and set featured Image from an external link
- Why does the Hard Crop option Scale?
- Post Thumbnails multiple sizes
- Long Post Title Misaligning Grid with Featured Image
- How to add multiple featured images to post/page without a plugin
- How do I set “Upload Image” as detault “Set Featured Image” window?
- Featured Image won’t display on Posts page
- Get post thumbnail from subpages with a foreach loop
- Getting images to show up in RSS Reader
- how i can increase Featured thumbnails size?
- the_post_thumbnail() Custom sizes not display correctly
- Set_post_thumbnail not resizing images
- How to inject attributes into get_the_post_thumbnail?
- How to get cropped thumbnail source for custom post type
- MultiPostThumbnails for Custom Post Type
- Muliple featured images (or just images) per post
- WordPress Featured Image function recreate
- Using Featured Image as Hero Background
- wp_get_attachment_image_src match smallest edge
- Can’t Set Featured Image [closed]
- Resize post thumbnail produces horrible image quality..Any help?
- media-library: how to insert thumbnails with a fixed width, regardless of landscape/portrait orientation
- Post thumbnail outside of loop
- query_posts adding two “post-entry” divs
- Display a thumbnail outside of the loop for a page
- Server B handling add_image_size() differently than Server A
- the_title() is not displaying over the_thumbnail
- Show posts image attachments
- Choose to Display Post Thumbnail?
- How do I make images appear in the beside blog post summaries?
- Featured Image meta box shows at the bottom?
- How to get a page’s featured image from a term slug (same name)
- WordPress generated thumbnails
- How to get featured image thumbnail to open larger version in attachment page?
- How To Use YouTube Url Stored In Custom Field To Get Video Image and Set it As Featured Image
- Display post thumbnail in foreach loop
- Add image size array to a portfolio thumbnail in combination with Masonry Jquery Plugin
- Define width of featured image thumbnails, but also make responsive?
- Add title to image post
- How to attach images that I “insert from url” into the post?
- If no featured image, add one of the default images into DB
- the_post_thumbnail(‘medium’) still gives thumbnail-size img
- Featured image for social sharing ot author archive page
- My Gallery Photos are showing in the post’s excerpts
- the_post_thumbnail not resizing
- How to add featured images to posts from a category
- How do you code a featured image into an XML as a jpg link, instead of using a data-id number?
- Cropped featured image
- Change featured image when changing viewport
- Adding guiding text to the ‘Featured Image’-box in the backend
- Thumbnails regenerate wp_generate_attachment_metadata
- Using the_post_thumbnail do not rollback to original image if specified thumbnail does not exist
- Get author image from corresponding article in thumbnail
- Missing image size
- water mark on featured post image in wordpress
- Making a ‘featured image’ become the image for a full banner (top of page) image in a blog post?
- How to change text of Remove featured image
- Add space under featured image in singel post
- Genereate widescreen featured images in different sizes
- set_post_thumbnail() shows Unattached on backend under Media
- How to get the URL of a each custom image size of a featured image
- How to add a class to figure tag for featured images?
- Recent posts show thumbnail
- Add Featured Image from Existing wp-content folder
- Featured Images missing on migrated site
- Post thumbnail won’t resize to fit
- Pointing Existing featured images to s3 bucket
- Displaying All Parent Pages as Featured Images
- Featured Images not appearing
- Editing featured image
- Using set_post_thumbnail inside save_post action gets overwritten
- WordPress save thumbnail but don’t show it [closed]
- Get all images from posts with maximum number and without featured image
- Display featured image as post thumbnail
- Scan for first image in post and display it [duplicate]
- Change featured thumbnail based on screen size
- Show a featured image with “Link” Post Type?
- Why not attaching images after impoting using wp cli
- How to display featured image caption only if exists?