Try to use that set of arguments :
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'post_parent' => $post->ID,
'orderby' => 'menu_order',
'order' => 'asc',
'post__not_in' => array( $thumb_id )
);
I’m using it for one of my site and it’s working fine. So you shouldn’t have to use :
if ($thumb_id==$attachment->ID) continue;
in your loop.
Strangely, the get_posts()
Codex Page (http://codex.wordpress.org/Template_Tags/get_posts) says that we could use a exclude
parameter, but also says that get_posts()
use WP_Query()
. And there is no exclude
parameter in the Codex for WP_Query()
(http://codex.wordpress.org/Class_Reference/WP_Query), only post__not_in
.
So, let’s use post__not_in
instead of exclude
.
Looks like a discrepancy.
Related Posts:
- How to get image title/alt attribute?
- How to change _wp_attachment_metadata specific value in SQL?
- How can I get a different image size, if all I have is the link?
- How to create resized versions of images added with wp_insert_attachment
- How to attach images that I “insert from url” into the post?
- How to disable WordPress from creating thumbnails?
- How do you get the post thumbnail size?
- set_post_thumbnail_size vs add_image_size
- Minimum Dimensions Requirement for Featured Image?
- Get the first image from post content (eg.: hotlinked images)
- How to get all featured image sizes and their URLs?
- How to Dynamically Resize WordPress Image On-The-Fly (custom field/theme option)
- Display thumbnail only if requested size exists
- Delete original image – keep thumbnail?
- the_post_thumbnail responsive srcset not populating with custom image size
- How to add multiple image sizes of the same size with add_image_size
- New image size version only for the Featured Image file
- Can’t extract and set SVG dimensions
- How to find attachment by it’s name?
- media_sideload_image generates blank?
- Getting custom-sized featured image’s URL?
- Showing a placeholder/default img, if no featured image is set
- Insert an image into a post by API
- Featured image with the same height thumbs returns wrong thumb
- Change Output for Images in Content
- Can WordPress crop only the post thumbnails?
- How to get the image sizes, in a function, as per the sizes mentioned in the media settings?
- Adding Featured Image to Post programatically
- How to get custom image sizes into media uploader dropdown?
- WordPress resizes image to the same size as uploaded
- add_image_size and add_filter(‘image_size_names_choose’, ‘my_custom_image_sizes’) not working with wordpress 3.5.2
- Show prev and next post links for parent post of current image in attachment page?
- wordpress responsive image srcset not working
- How do I get a random image from subset of images in media gallery?
- Delete all thumbnails for a post
- How to set an attachments parent post id in code?
- Why are extra 92 pixel square thumbnails created?
- wp-cli regenerate media is not working for custom sizes
- Remove dimensions from filename featured image
- Can a thumbnail of an animated gif be animated?
- Converting Attachment to Images?
- WordPress Uploader Editor shows broken image
- add_image_size not working with the_post_thumbnail
- How do i show wordpress attachments from current post?
- Need clear explanation about medias/files/attchments
- Why does the Hard Crop option Scale?
- How do I set the default “feature image” size?
- How to get full absolute url for post attachment?
- Thumbnail Cropping with add_image_size?
- If I Regenerate Thumbnails, would WordPress delete the existing Thumbnails and replace them with ‘new copies’?
- How to get cropped thumbnail source for custom post type
- Exclude featured image from gallery code stops Lightbox from working
- Set size for attachments
- Featured Image Not Working when loaded from sub-domain
- How can I see where in my themes and plugins certain image sizes are used?
- Generate image for newly added size
- wp_get_attachment_image_src match smallest edge
- Custom image size in the_content loop
- specify size of post preview image (not post thumbnail)
- Display featured image file size, extension, filename, type, orientation?
- media-library: how to insert thumbnails with a fixed width, regardless of landscape/portrait orientation
- Server B handling add_image_size() differently than Server A
- Post thumbnail throwing size limit parameters in
- Get thumbnail image according to the screen
- How do you import images from a URL in your post?
- images not showing despite using add_theme_support(‘post-thumbnails’);
- Retrieve Image Attachments Getting Post Thumbnail Image First
- Trying to show link “Use as featured image” from Attachment window from t31os script
- post thumbnail: increase dimension if smaller than… Possible?
- Images uploaded on frontend display correctly but not in media editor.
- Make image full width
- How risize a thumbnail?
- Unrestricted height thumbnails
- custom thumbnail image size not working
- WordPress not creating “large” thumbnails
- Custom caption output for custom image size
- Display post thumbnail in foreach loop
- the_post_thumbnail(‘medium’) still gives thumbnail-size img
- How to update custom image sizes?
- Attachment Image using wrong src?
- Moved server, and WP now uses original images for all thumb sizes?
- Custom image size not displaying with wp_get_attachment_image()
- How to echo images Urls from a wordpress post, that are relally in the post
- replace featured image from frontend
- Thumbnails are hard cropped not matter what
- Featured image size always cropped bottom
- Using the_post_thumbnail do not rollback to original image if specified thumbnail does not exist
- Missing image size
- Post thumbnail not displaying correct size
- Making a ‘featured image’ become the image for a full banner (top of page) image in a blog post?
- wp_get_attachment_image_src() works on index, but not on Archives
- Setting featured image based on related post
- Trouble Retrieving Thumbnail URL on Front-Page
- setting featured image is not working while running script in background, works when running that script from browser
- Editing featured image
- Get all images from posts with maximum number and without featured image
- How to modify Media Library images DPI [ image quality down to make small in size ] [closed]
- How can I use an image from an external source without uploading it to the media library
- Why not attaching images after impoting using wp cli
- Close featured image modal windows with JS