I don’t think that you can use get_the_post_thumbnail
function to get last uploaded media, but you can use get_post
to get latest attachment and then wp_get_attachment_image to display images.
$attachments = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => 1,
'post_status' => null,
'post_mime_type' => 'image'
) );
foreach ( $attachments as $attachment ) {
echo wp_get_attachment_image( $attachment->ID, 'thumbnail' );
}
Related Posts:
- Adding a custom image upload size and making it selected by default?
- Change the filename format of saved featured images
- How to register images uploaded via FTP in media library?
- Create Image Uploader for Widget
- Using file_exists to check file in Uploads
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Rename image uploads with width in filename
- Debugging upload problem: What part of WP does actual image-resizing?
- How to resize image on client-side before upload?
- How to upload imagick resource to media in wordpress
- Adding a querystring to an image URL when clicking ‘insert into post’?
- Validate Uploaded Image using WordPress’ Built-in Functions?
- Convert all images to PNG on file upload
- Can’t upload image using media_sideload_image
- Upload multiple images to a Woocomerce product
- What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?
- Enable custom logo upload if logo is not in header
- WordPress automatically adds links to uploaded images
- WordPress function when file is uploaded, deleted or edited
- Get featured image with custom size outside WordPress
- Images Uploaded saving onto older/previous year folders
- Convert canvas to image and upload image to server
- WordPress İmages Upload & Delete Error
- How to Make Thumbnail of Post Stay Animated
- Convert all uploaded PNG files to PNG-8 format
- Some problems in custom widget
- Checking page before applying image restrictions while uploading
- WordPress loading all local images from specific directory?
- Save the outputted image into the Media Library, with a different filename and extension
- How to resize an image server-side before upload?
- Name Input from widget displays Sidebar name instead of saved data
- How to automatically convert images to WebP on WordPress?
- Generate and upload screenshot as featured image for user-submitted post
- How do I hook into WordPress to save an uploaded photo as an alternate size to an existing photo?
- How to check if image is already stored in a site’s post database? (network)
- How to draw media details for Isotope gallery using Photoswipe
- Image Upload “exceeds the maximum upload size for this site”, but php.ini is correct
- Failed media upload: “The uploaded file was only partially uploaded.”
- Permanently remove first image from posts
- Is it unsafe to put php in the /wp-content/uploads directory?
- WordPress media upload “HTTP error”
- How to get custom image size for image uploaded in Customizer
- Restrict WordPress File Type Uploads by User Type
- Using wp_get_image_editor in a standalone script
- Modify Maximum upload file size text
- Upload a json file in php [closed]
- Styling images coming from another blog
- IMG src weird behaviour inside a single post loop
- Escape post image attachments added to template
- Display post image with fancybox
- Upload Image in a WordPress page using PHP
- WordPress (3.9.1) MultiSite Permissions. Is chown the answer?
- PHP code to call image Caption, Alternative Text, and Decription?
- Echo URL of large version of Featured Image
- Change the URL of an image from wp_get_attachment_image_src except in the frontpage
- how to retrieve uploaded url of zip files
- Why is $_REQUEST an empty array in admin-ajax.php?
- Best practice for migration friendly images in posts/pages?
- Get the post ID and display the images
- Responsive Header for Phone
- Upload file could not be moved to wp-content/uploads
- Why my image upload button is not working in wordpress widget area?
- How to make own crop image function for WordPress plugin
- How do I Import / Upload Files with jQuery AJAX?
- How to loop through all the attached images in a post, and get their url one by one
- Clickable image link sends people to wrong URL
- Only show image from custom field when present
- Timthumb.php image gallery not working on Multisite WordPress
- Upload multiple files in randomly generated folder using wp_upload_bits
- Change default gallery images – Currently they are displaying full size imagese
- Can’t upload CSV file to plugin directory using custom upload form in admin panel
- Creating black and white copy of an image [closed]
- Display an image based on field value
- How do I increase the upload size only when editing special pages?
- How to set a featured image (thumbnail) with PHP?
- Get URL of Featured Image After wp_insert_post()
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- Adding a ‘style=’ bit to image_send_to_editor output
- Displaying images outside the content
- Hook on file upload
- Retrieve alt text by referencing the img src
- Show next image in array if page is revisited by same logged user
- Update Images after edit via php
- How to get the url of the entry in which an image belongs
- Change upload URL by mime type
- Crop an image after upload on custom account page
- Restrict File Type Uploads by User on Wordress via functions.php
- How do I routinely extract the thumbnail of the most recent post?
- Renaming “Expand Details” within “Add Media”
- add class to background image
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Creating image gallery in wordpress
- Image limit from 1 to 5
- Gallery requires a featured image but does not show it in posts/pages
- Can’t upload files
- Edit Image/Image Details – Replace button missing
- Understanding responsive imagery
- bloginfo url in javascript
- WordPress directories not writable after PHP version upgrade
- Adding caption to all images inside an article