Set orderby to post__in
. This preserves post ID order given in the post__in array (available with Version 3.5).
$args = array (
'posts_per_page' => -1,
'post__in' => $ids,
'orderby' => 'post__in'
);
Related Posts:
- pre_get_posts order by not working
- Help ordering Post loop by two meta values
- Order ascending is ignored in meta query?
- WP Query – order posts by meta field first and then order the rest
- Child pages not affected by orderby
- Order posts by custom column using pre_get_posts
- How to put posts with some taxonomy on top of others in `pre_get_posts`
- When to use WP_query(), query_posts() and pre_get_posts
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- WP_Query orderby date not working
- What is “main query”? [duplicate]
- Order by optional meta key?
- WP_Query order by multiple meta keys & fields
- Reduce or prevent calling of update_meta_cache
- How to add taxonomy filter on the query fly?
- How to get order of posts?
- Order posts by ID in the given order
- Order Search Results Page by meta_value If no Value Return Remaining Results
- Sorting posts by custom date fields (non standard date format)
- pre_get_posts with get_posts
- How-to exclude terms from the main query the most performant way?
- How do I order pages and categories by ID or name in the same query?
- RSS feed with specific keyword
- Multiple orderby parameters in pre_get_posts() action
- Merge 2 args in one WP_Query and order it by date
- Query with pre_get_posts to get pagination
- Revolution Slider Orderby Two Custom Fields
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- Can not switch the queried post in pre_get_posts hook
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- WP_Tax_Query with post_tag not working
- How to Modify Taxonomy Archive Page with Search Parameter?
- Custom Post order for homepage
- pre_get_posts filter meta_query without conflicting existing meta_query
- WP_Query Order by Specific Post ID First
- How to change posts order on Category and Tag archives?
- Sorting posts DESC based on the number of comments using WP_Query
- My Main Query Modification is Messing up my dynamic main – why?
- pre_get_posts Remove tax_query Completely
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- Adding a parameter to the default query
- Using WP_Query in “parse_query” or “pre_get_post” in Posts2Posts
- Orderby ASC changes to DESC in WP_Query
- How to set multiple `orderby` in query argument?
- Remove category from query (show all posts in archive.php) pre_get_posts()
- Weird orderby => post__in issue
- WP_Query ignoring tax_query when is_singular
- Order by empty custom field
- How to order posts by title after they have already been sorted by category
- Advanced ordering of query_posts
- Applying posts_clauses filter to specific queries only
- New WP_Query calls Pre_get_posts filter twice
- Ordering posts by an array
- How to Create a Random List of Child Pages
- Specify strict ‘order by’ in WordPress query
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- pre_get_posts – editing query, tax_query
- How order posts from category by date and comment count?
- WP_User_Query orderby meta_val_num
- WP_Query custom order and pagination
- Sorting posts by Multiple custom fields in defined order
- Sort posts using multiple custom fields and menu_order in single query?
- Elementor posts custom query based on tag [closed]
- Exclude post with taxonomy and from the terms (taxonomy & tag) posts count
- `offset` WP_Query argument dont work via `pre_get_posts`
- WP_Query order by multiple meta keys & fields
- pre_get_posts pagination not working
- How to sort wordpress posts already selected by WP_QUERY
- meta_query is overriding default search
- Custom WP Query order function possible?
- Custom order revolution sliders post base slides as inserted in Specific Posts List field
- WP_User_Query Orderby Not Working
- Order by value of Custom Field using url string
- Order posts by tags count?
- Order Element By Custom Field in WordPress
- Pre get posts sort by meta key returns no results if meta key does not exist
- Sorting with meta_query and multiple, optional meta keys
- Pre_get_posts only show posts by administrator roles
- Modify a query with no results in pre_get_posts
- How order by works?
- Custom Order Current Query: By Meta Key and Category
- WP_Query: custom orderby (not ASC nor DESC)
- Order & Orderby clause not working with custom query
- why doesn’t this pre_get_posts code work?
- pre_get_posts with WP_Query to prevent posts from specific tags
- Best way to Order Post in Home without a plugin
- orderby in WP_QUERY – Use the order from the Dashboard
- Query All Attachments and Order by Parent Publish Date
- Using orderby with 2 meta keys
- wp_query – Modify $query to include duplicate content
- Add filter to Orderby Parameter using Array
- Order WP_Query results in order other than ASC or DESC
- Custom query to order by multiple taxonomies
- Filter WP_Query output before it is accessed (pre_get_posts)?
- query_posts with sorting on a custom datestamp
- Get post closest to today
- Posts2Posts, wp_query and orderby issue
- Avoiding page loop
- Change posts archive ordering
- orderby and order filter in get_posts or WP_query function in wordpress not working