Add post__in (two underscores) to your $args:
$args = array(
'post_type' => 'attachment',
'post_mime_type' =>'image',
'post_status' => 'inherit',
'posts_per_page' => -1,
'post__in' => array( 161, 162, 163, 164, 165, 166 ),
);
Reference
Related Posts:
- Upload images to remote server
- How to delete resized (cropped) image uploads and prevent future resizing?
- Why is wp_get_attachment_image_src not working with my custom size (add_image_size)
- Images dont show in grid view, but do in list view
- How can I hide media library images from general users?
- How to rename an image attachment filename using php
- Remove duplicate images from media library.
- WordPress function: limit size, only jpg, jpeg, limit of uploaded files per account
- Cannot access the thumbnails of attachment images… Cannot find the reason
- Why would image paths in wordpress suddenly change?
- Import Images from one self-hosted WordPress install to another
- Uploading images to Media Library fails with Memory Exhausted
- Edit image preview is not displayed
- How can I autopopulate titles in the media library?
- Upload thousands of images to WordPress without plugin?
- Get author ID with attachment ID
- get_attachment_id() only get id of first attached image after post update
- Different upload path per file type
- Images are randomly deleted from server
- HTTP Error when uploading files above 7mb unless using GD Image Editor
- Consolidating two websites into one, but migrated images not appearing in Image Library
- wordpress media library shows empty images
- Shortcode for a link and thumbnail
- Check if the image exists in WordPress media library
- unattached media files that should be attached
- How to output images as figure/figcaption
- Bulk edit of EXIF data for jpeg images uploaded in the media library?
- offload media to external services [closed]
- How to upload images in a specific folder using API
- AJAX – save an $_FILES picture in media library
- In Wordress one author can not see the other’s author uploaded images through media library
- How to open default wp image editor screen dynamically?
- How to prevent WordPress scaling large images down
- Is it possible to split Default WP Media directory to multiple Folder/Subdomain?
- Searching for any images in media library displays “no media found”
- How to get file URL from media library
- Images uploaded to the media library has strange colors. However, in the edit screen the color is ok
- Change media URL (images)
- Add custom text in the media library image meta area
- Custom Loop, Match Category with Page: How to display post featured image?
- Uploaded images not displaying in network site
- Unable to upload images to the Media Library. Getting this erron on the console wp-admin/async-upload.php 403 (Forbidden)
- What happened to the media manger?
- Why does WP allow to view and media item as a page
- How to limit the number of images displayed in the media window?
- Images are not showing up in “Uploaded to this post”
- Create a post from every image in my media gallery
- Get images attached to a specific page
- Retrieve Image Attachments Getting Post Thumbnail Image First
- Images don’t update after being edited
- Is there a way in WordPress to convert images to WebP without a plugin?
- Change Image folder Locations
- Rebuild thumbnails via WP Cli – how?
- Auto delete pictures in media library by age
- Some Images Disappeared from Media Library?
- are unattached media files a problem?
- WordPress Attachments with old images
- Large image not showing dimensions in Media Library
- Fetching uploaded images using Link URL
- Random Image Script Working but Want to Avoid Duplicates
- How can i sorting and display image order by siz in media library?
- Allow wp media library to check already selected images displayed in div
- WordPress append -1 to the image name
- Custom Image Widget
- Media Library Cleanup A Thought Exercise
- Do I need to re-register all my images in the media library after a migration?
- Could creation of various image sizes cause slow form submission response?
- unsharp thumbnails after uploading image
- imported post image as normal image instead encoded image
- still need help-images inside wp-content/ uploads/ are not showing up in my media library and uploaded using FTP protocol
- The image keep redirect to my previous URL after I moving my site
- WordPress Link To Image Missing Dropdown
- After moving a site to new hosting, not all images are showing in media library
- List sub pages with custom field content converting image ID to URL
- Edit image itself
- add titles to images in ad media in pages and posts
- Change the image for a certain URL
- Assign one featured image to multiple posts?
- Some images don’t get linked when setting link-to to media-image
- Missing Images in Uploads Directory (Server Only)
- How do I embed an image at actual size?
- Image media upload problem in page editing modus?
- Broken Media Library
- Transfered live site to new server and images are not showing
- Limit files uploaded per folder
- how to display all images from their siblings/ from same parent?
- My image rotate 90 degree
- WordPress can’t get image url but both the attachment and the actual file are there
- Why some images are not allowed to be edited only for thumbnails?
- My subdirectory sites images (except webP) are throwing to 404 page even they are exist
- Media Library shows default image instead of image preview
- How can I use an image from an external source without uploading it to the media library
- Images have dissapeared from media library and site
- Is there a way to upscale a media library original image to the nearest whole pixel in WordPress?
- How to make Media Library files private?
- Media Library Issues
- Trying WP editor to load full size image (not ‘300×300’)
- “Media Library” shows as empty, despite images being present
- Why are PDF thumbnails over-saturated?
- How do you detect when an image has been deleted from WordPress media library?