You don’t get any ordering, because you are making multiple get_posts()
calls and only retrieve a single post in each of them. You cannot order a single post. 🙂
You need to get rid of outermost loop and just pass a set of IDs (that would be your $instance['data']
) to retrieve via single get_posts()
call.
Related Posts:
- How to get attachment file name not attachment URL
- Get attachments (get_posts) and WP 3.5 new uploader
- Get a Page’s attachments in Gallery order
- attachments with tags and get_posts
- Ordering of gallery images without using shortcode in theme
- Query to only return the 2 newest post attachments (images)?
- Get title of post image is attached to
- How can I return multiple image attachments with wp_get_attachment_image_src
- How can i catch (with get_posts) attachment file (pdf, images) from a post when i have only inserted it from media library and it isn’t upload for it?
- Can’t sort get_posts by post_mime_type
- Retreive tags from attached post for media on page
- Change attachment inside the_content using filters
- Can I add a Category Metabox to attachment?
- Disable Attachment Pages Completely
- Get all post attachments except featured image
- How can I bulk delete media and attachments using WP-CLI?
- Changing attachment urls?
- Add custom class to attachment in media library grid mode
- How can I UN-attach media from a post?
- How to get attachments for a specific post type?
- Make individual attachments private?
- Change the Permalink for wordpress attachment
- Get the attachment URL on single.php
- How to get list of paths (not urls) for an image
- Adding Featured Image to Post programatically
- Getting movie and serial on actor page
- POSTS list in WordPress by views
- How to count media attachments?
- Insert custom ID into wp_get_attachment_link
- How to add attachment without uploading?
- How to get images from EDD post?
- List of posts by day of the week
- Reorder “menu order” of attachments to another predefined order
- Change code to display image attachment page
- Add image attachment to post via coding?
- How To Grab All Type Of Attachments, But Images?
- Removing width and height attributes from wp-get-attachment
- Change filename during upload
- Get post attachment images dimension and use in embed code
- use wp_get_attachment_image() to show attachments
- List Post Attachments – Remove Image Thumbnails
- How do i add LIGHTBOX to Attachments?
- How to specify width and height in the_content for image attachments
- delete image attachments of a custom post type except featured image
- Import Attachments – not attaching to post_parent
- Sort query_posts for Parent Pages to menue order or the count?
- How to redirect ‘file url’ to ‘post url’ i.e. in attachment.php
- Order posts by custom field DATE value
- Remove the first 5 characters of the_title and orderby that
- Open post-content in archive page in a Modal box with bootstrap
- hook wp_generate_attachment_metadata does not read all the attachments
- Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?
- Display latest x posts from all categories in Custom Post Type/Taxonomy
- Massive photogallery import
- Only showing the_date and the_excerpt for first entry in get_posts
- Delete associated thumbnails when calling wp_delete_attachment
- How to allow empty title for attachments?
- How i can get post data from database when i am getting post id from url in wordpress
- Retrieve Image Attachments Getting Post Thumbnail Image First
- How can I display a link to a post’s (Word doc or pdf) attachment?
- GUID field in wp_posts – relevance for attachments?
- Gutenberg Block: Image resolution
- Attach a external file as attachement using wp_mail
- Get image attachment to a post outside the loop?
- Prevent image from being accessible via url as a post?
- Upload multiple image with media_handle_upload with multiple file field [duplicate]
- Delete child post and attachment links to parent post
- Remove attachment from database
- How to get the next and previous image title from attachment or gallery?
- Display Audio Attachment URL
- Display a post attachment depending on the caption
- Add class to every other posts using get_posts
- changing the default picture size link url
- Get an image from the media library. Struggling with the code?
- get value from get_post_meta then reuse it in another get_post_meta
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- I’m having trouble with Related Product “tax_query” ‘terms’ value
- Programmatically Altering Gallery Link and image size?
- Attach and retrive multiple pdf files to post or page
- Get list of posts from attachment
- File was uploaded, but it is not shown on media section of the dashboard
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- Displaying POST content with HTML tags and all
- Media Library Category Exclude Tree
- wp_get_attachment_metadata is empty
- Orderby taxonomy term id using get_posts not working
- Restricted Attachments/Change Attachment Upload Location
- Hide Image Container if No Image Attachments
- Attachments doesn’t update
- How to link images to attachment.php [duplicate]
- Check whether attachment ID is associated with more than one post?
- Possible to “Attach” images to multiple posts without uploading twice from Add media Section?
- show/hide attachments
- ID of images from gallery
- WordPress Attachments vs Post Meta
- open image after clicking on single.php with different stylesheet in wordpress
- How do I get link URL (not file URL or attachment URL) of an attached image [duplicate]
- Attachment page custom title?
- No attachments on contact form 7
- wp_mail attachment not working in wordpress