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
- How do you create an attachment ID with Ajax submit? No page refresh
- What will happen if I delete all my attachment type posts from database?
- How can I make an attachment page for pdf uploads?
- Proper use of wp_get_attachment_image?
- Auto create file and send it via wp_mail()
- Create page from post attachments
- While loop articles – if statement order
- filter get_children to return all mime types EXCEPT ‘x’
- PHP Syntax Error on get_posts
- Returning data instead of echoing/printing
- how to get random media id from media gallery
- Attach pdf from dynamic url
- How to Loop Through all Posts and Count Attachments using Get Media Attachments
- How i can get post data from database when i am getting post id from url in wordpress
- get_total () returns 0 – woocommerce [closed]
- Output meta into arrays
- Weird string offset errors when displaying post attachments
- How to use WordPress Conditional Tags in get_posts foreach loop
- Display all pages – in order
- Retrieve Image Attachments Getting Post Thumbnail Image First
- the_time() returning wrong date/time (way in the future)
- Specify strict ‘order by’ in WordPress query
- Add audio attachment link to RSS
- How to retrive the text : No movie by this actor
- Correct attachment size
- Post Gallery list attachments except the one used as post thumbnail
- Echo Permalink in Attachment outside of loop?
- How can I display a link to a post’s (Word doc or pdf) attachment?
- How to: Retrieve an attachment image from post and output it
- GUID field in wp_posts – relevance for attachments?
- Links to my uploads went crazy
- hide attached images of a post
- Gutenberg Block: Image resolution
- Is it possible to use array_walk() to append terms to an array of posts?
- Attach a external file as attachement using wp_mail
- Is there a function for getting the post/page that an attachment is related to?
- How to get $attachment->ID in custom functions
- How to get image from url from the database?
- WordPress query reverse order
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- WordPress Random post (last 3 days posts)
- Find out last 7 days of upload images, last week uploaded image from Gallery and display them in different pages
- Get image attachment to a post outside the loop?
- ‘child_of’ in get_posts not working
- How to add a caption to an image attachment in a file list?
- Could not get attachment using wp_mail
- How to get the filename from file system and create a download link?
- Looking to limit file attachment downloads
- meta query not retrieving posts
- Echo list attachment size in post
- How do I intercept and modify the functionality of wp_get_attachment_image()?
- Unable to render custom field after attempt to generate a list of recent post in page template
- how to get attached file url for current post?
- Order post by taxonomy
- Prevent image from being accessible via url as a post?
- Upload multiple image with media_handle_upload with multiple file field [duplicate]
- All attachment pages give 404
- 500 internal error at wp_generate_attachment_metadata
- Delete child post and attachment links to parent post
- Let users upload image(s) to the post from front end
- Front end file upload returning wrong attachment url
- Undoing define( ‘UPLOADS’, ”.’files’ ); to repoint to “wp-content/uploads” folder
- List all pages including archive
- Unable to get wp_get_attachment_url to show
- Yet another get_posts() in explicitly defined order problem
- Remove attachment from database
- Get Attachment Image Class by attachment id
- Attaching images to posts manually (i.e. with custom code, without the use of an API)
- has_excerpt yields true but no post_excerpt when retrieved
- Automatically deactivate link for attachments
- How to let a role handle media without post permissions
- Hiding or removing file extension displayed in HTML on attachment page
- After changing permalink structure, How to redirect attachment url to old parent post url
- WordPress Gallery Permalink Structure Displaying Incorrectly
- Upload image and assign it’s id to post
- How to get the next and previous image title from attachment or gallery?
- Display Audio Attachment URL
- Possible to add “Even/Odd Classes” to image attachments via wp_get_attachment_image?
- Adjust the order for returned posts
- How to set order for attachment form field?
- Will wp_get_attachment_metadata display PDF metadata (eg: keyword, author, description)?
- Display a post attachment depending on the caption
- How to get thumbnail from post attachment in this loop
- Add class to every other posts using get_posts
- Getting attachment post using wp_get_attachment_link
- How do I get just the title from wp_get_attachment_image
- changing the default picture size link url
- i want attachment.php to return the image