You would need to build your own query and pass it to query_posts i.e.
if your array of post ids is:
array (10,21,1) // corresponding to post ids.
then you can query this way:
select * from wp_posts where `ID` in (10, 21, 2)
order by field(ID,10,21,2)
This will give you a result set in the order of your post ids array.
HTH
Related Posts:
- Sort posts alphabetically by custom field value, insert divider between different letters
- How to Get All Posts with any post status?
- How can i get count from query post
- query_post by title?
- How to query_posts using meta_query to orderby meta_key AND have a secondary sort by date?
- How to return results of a get_posts() in explicitly defined order
- How to set posts per page using WP_Query()
- query_posts() in function makes global $wp_query out of sync?
- Problem with ‘post__not_in’
- Is it better practice to use query_posts, WP_Query, or get_posts to create various custom loops within a Page?
- Sort X categories by last update and show image
- Custom Post Type “Event”: chronological list of recurring events
- Sorting problem with ‘query_posts’ funcion in wordpress. Sort by custom field not working
- Total Count of Posts NOT in Selected Categories?
- query_posts sort in multiple directions
- Using database meta_values to calculate new post order using pre_get_posts or a ‘request’ hook
- Sort Posts by Multiple Meta Values [duplicate]
- orderby:date not working
- Sorting multiple custom post types without a meta key/value pair by sort order
- Tricky WP Query
- WordPress pagination showing same posts on each page
- Search breaks when querying main loop for category
- Using ajax with paging and a custom sub-query
- Custom loops, sticky posts, and pagination nightmare
- change the default order of posts only for specific categories
- odd behaviours from template tags
- Having an issue doing a WP_Query with post_content and category__and
- Custom query looking at multiple custom fields and properly sorting
- Pre-existing arguments when using queries
- Sorting the Loop by Taxonomy Value
- WordPress sorting posts by date and title using a dropdown
- Sort / Filter Queries
- query_posts with sorting on a custom datestamp
- wp_query by last month + sort posts
- If meta_key has value = 6 | Change the wp_posts.post_date to current date
- How to refine WP-Query with further criteria
- Run second query on page based on author of the first query
- Query Posts (post meta)
- posts_per_page no limit
- Query posts: how to exclude results if post is in multiple categories
- query_posts ->using meta_compare / where meta value is smaller or greater or equals
- WP 5.8 “Query Loop” block: where to place custom query?
- Meta Query with date and time on the same Day before given time
- order post my meta value m/d/y format with year as included value
- _wp_page_template to dynamically use template
- how to display active, upcoming and past event with featured listing with pagination
- Problem with single-page for my custom post
- How to make the list of post and load on same page with sub-pages [closed]
- How do you query wordpress posts using a math formula between multiple meta field values?
- Custom query shows custom post types in trash
- Custom category search box for WordPress
- How do I make archives.php for one category only?
- making random query button using $_GET
- how to exclude “featured” posts from the main loop?
- Slow WP_query due to nested wp_query. Need Suggestions
- Five posts from a category in footer
- pass query string on url to filter media
- Co-authors plus problems with query_post
- Error sending array of inputs
- How to exclude latest x posts from a paginated query?
- Help ordering Post loop by two meta values
- How to exclude post formats from wordpress recent posts in a tabs widget [closed]
- How to sort a custom wordpress query by combination of meta values?
- Adding conditional content to single post-type template
- Query Posts by Custom Field
- Easy way to write complex queries in wordpress
- I am having problem sorting custom post type using WP_Query
- Pagination on category.php and tag.php not working
- Currently using a query_posts() in my theme – want to use a request filter in stead
- Random posts that always include a particular post?
- Order for custom field after the loop
- Custom post query error
- Why doesn’t my WP Meta Query return any results?
- Multiple instances of query_posts
- If Query Post Returns 1 Post
- Change content off every sixth element
- How to get any type posts include attachments by ids?
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- Filter products on category AND tag
- How to create loop of posts except post ID defined via ACF field
- How to sort wordpress posts already selected by WP_QUERY
- How sort products by calculate value? ( custom post meta, price, option)
- How do I stop the same post showing multiple times in a archive?
- Wp Query sort order from custom MetaBox
- Case insensitive ORDERBY in wpquery
- How to mix two orderby-parameters into one ordered result
- allow user to edit posts made by others users based on the user role
- Fetching $_POST from Page Template into functions.php
- Custome column sort by date not title
- WordPress custom post type
- Post per page not working
- Show previous month’s posts
- query_posts result differs from wp_query request result
- Collect posts from last 48 hours
- wordpress sorting using array merge by price in ascending order but price with 0 must be show last
- Create “archives by year and week” by category template
- Display ACF object field data using Elementor Custom Query
- WP Query – Show custom posts only if user contain some user meta
- Show number of posts AND number on current page (cannot make it work)
- /page/2/ redirect to 404