If we want to exclude the featured post image then here’s the one-liner updated:
$ids = join( ',', wp_filter_object_list( get_attached_media('image' ), [ 'ID' => get_post_thumbnail_id() ], 'NOT', 'ID' ) );
here it’s expanded:
$ids = join(
',', // join array by comma
wp_filter_object_list(
get_attached_media('image' ), // fetch attached images
[ 'ID' => get_post_thumbnail_id() ], // filter ID equal to featured image ID
' NOT', // filter operator: NOT
'ID' // pluck the IDs (only include)
)
);
Related Posts:
- Add custom Attachment Display Setting for images
- disable WP automatically inserted line breaks after an image
- Delete the original big size image after upload and leave only 3 images crunched by media gallery
- Add existing images from Media Library in to custom gallery
- Replace image attributes for lazyload plugin (data-src)
- How do I detach images from posts?
- How do I sort (order) the results from `get_children()`?
- upload image in a meta box
- How do I use element instead of tags in WordPress post content having webP support?
- How to remove images from showing in a post with the_content()?
- upload featured image from front end using wordpress add media button
- How do I create Comma Separated list of attached image ids?
- Get post embedded image caption
- Remove image from post also removes photo from media library
- Post taxonomy from exif data
- All my inserted images gets a link to the full image even if it is already full size image
- get custom image size
- How to get only text from wordpress post content?
- Get all images out of the posts content
- how to replace embedded “full” sized images within a post with the “large” ones
- Batch process: remove first image from post content
- how can I put an image in a post with original size
- Show featured image next to post-teasers in Genesis Framework?
- How to retrieve the postID in a “image_send_to_editor” hook function?
- Modify Image Source With The_Content Filter?
- Featured Image uploaded, attached and set but only appearing in the media library
- Load post attached images on a single page site with fancybox
- Format the Layout of Images In The Edit Post Textarea?
- Set size for attachments
- I have a site where attachments in the wp_posts table have guid values of guid, how did this happen?
- CSS: How can I show a photo beyond the template’s column, but contained within the browser window? [closed]
- Get all attachment by post excluding featured and content inside
- wp-cli post create & media import issues
- Show only posts with images and a fixed amount of posts
- How would one change the default url structure of attachments?
- If statement to check if post has image
- Gather posts into a cart/lightbox and share with another user
- What are the benefits of setting a “featured image” for a WP blog post?
- update image path with words starting uppercase to lowercase chars
- How to only publish posts with image in it
- Uploading images in custom post form
- Make insterted image point to post url instead of attachment page
- how to give multiple post thumbnails to a post
- Posts page not showing correct image
- How to allow multiple thumbnail upload for Posts?
- get_children returns older images
- How to display post title inside thumbnail?
- How to remove text and retain in caption image using the_content function
- How to get all inline images in post content? [duplicate]
- How to Featured content with images in home page?
- How to show a featured image inside a post in only 1 single category
- Inserting Media to WordPress Posts
- Author Avatar as default first image
- Link post images to post
- How to get the next and previous image title from attachment or gallery?
- Attachment image single page
- Only show featured image on exerpt and exclude images in post
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- how can display a post on home screen without images
- Changing The Default Header POST Title and Description text by category in wordpress
- Site/Post preview is not working on all social media
- How to exclude native lazy loading from first image in post content?
- Rewrite image links from attachment id to attachment link
- Delete media from the post but keep my featured image and post
- Aligning images in the wp editor not working. How do i get this to work in custom theme?
- unable to write to the database while uploading images
- Pinterest button shows image options from different posts
- Change the size of the featured image for post?
- Thumbnails and images in the blog post are not loading
- Modified core/image rendering not showing in posts – only on pages
- Post images are not displayed in media library
- Delete attached images from posts
- Blog images not showing on homepage
- Schedule image post on download
- Integrate video and iframe in a post type gallery
- Set featured image on creating new post
- how to create other sizes of original image in one go wordpress uploads
- Output wp_link_pages as raw url
- Embed image in post from external url
- Is possible to do this from function.php
- Stop images from being displayed on the front-end of the site
- Relative Image Urls in Posts are starting from root – Not from WordPress Address (URL) at General Settings
- WordPress Media URLs?
- Featured Images link to post parent
- SQL query to remove first image in all posts
- How do I insert a custom field in a user submitted post?
- Assign custom class to post content images
- Post thumbnail height problem
- Get attachment if matches a variable
- Import alt text in set_post_thumbnail
- Broken images after importing posts and opening in Gutenberg
- Search doesn’t display posts with images
- Displaying all images from a WordPress post (including media library)
- How to move all images in a post to a single gallery for a bunch of posts?
- Inside post image title has been posting as a post title on my main post page
- Download button under all images WordPress
- Images being uploaded via WP Media are not attached even they are used by some CPT posts
- how to display the actual size of the picture in post
- WordPress portfolio posts: media not displaying if several images
- Set Featured Image of a post