Starting in WordPress 3.5, the orderby
parameter will allow the value post__in
to sort by the order of the post__in
parameter, just like in your example.
It may not be ideal to wait or require 3.5+, but this will almost certainly be the best and easiest way to do what you’re looking to do.
Here’s the relevant trac ticket if you want the details.
Related Posts:
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- Some doubts about how the main query and the custom query works in this custom theme?
- WP_Query vs get_posts
- Query Posts in a Predefined Order
- How to get order of posts?
- Get the number of posts from the current page results
- WordPress Custom Query to show posts from last x years
- How to order posts tag by tag?
- Query Custom Meta Value with Increment
- WP_Query ordered by custom field that is a date string?
- How to query ‘posts_per_page’ to display a different blog posts index template?
- Show all parents and children in custom post type in right order
- WP_Query Order by Specific Post ID First
- How can I pick a single post from the latest 3?
- 2 loops on page – one with orderby rand second orderby date
- Query posts by specific word on title
- Five posts from a category in footer
- Multiple loops without repeating content
- WP_Query condition affects posts_per_page count
- Order by empty custom field
- How to order posts by title after they have already been sorted by category
- Some doubts about how the main query and the custom query works in this custom theme?
- How do I rewrite this loop as a new WP_Query style-loop?
- Include current post into loop
- WP Query – order posts by meta field first and then order the rest
- How to provide meta_key array to wp_query?
- get_posts output always same post
- How to create custom query by keyword in post title?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Conditional operator OR not working with custom fields
- Get posts that do not have the same tags as current
- Should I reset $wp_query?
- Filtering by multiple conditions in the loop
- 2 queries with counters
- WP_Query orderby random do not repeat infinite scroll – one loop
- Paginate pages with dynamic query
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Determine if ID is page or post and query the ID
- Custom template for password protected page
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Duplice post with standard WP loop – fixed by using query_posts() instead
- How do I stop the same post showing multiple times in a archive?
- Order by meta date with a thousanth of a second defaults to post order
- Custom query for custom post type not getting correct post ID
- Problem with my loops
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- Display three sequential posts on each page load, without repeating previous
- query_posts() doesn’t seem to be called in my page
- Some doubts about how the main query and the custom query works in this custom theme?
- Ordering Posts by parent category, name ascending
- query_posts with sorting on a custom datestamp
- Order by multiple meta keys on wordpress
- Converting an existing query_posts to WP_Query
- Multiple loop for “featured” items returns wrong posts
- Show number of posts AND number on current page (cannot make it work)
- new WP_Query with order args – no more distinction between categories
- When should you use WP_Query vs query_posts() vs get_posts()?
- When to use WP_query(), query_posts() and pre_get_posts
- Get post ids from WP_Query?
- Nested meta_query with multiple relation keys
- How do I exclude a custom taxonomy from the post loop
- Can I force WP_Query to return no results?
- Resetting post data to previous loop in nested loops
- Wp get all the sub pages of the parent using wp query
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Get post count of current loop when using multiple queries on one page
- Multiple WP_Query loops with Pagination
- Using a custom WP_Query with get_template_part loop
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- How to query for most viewed posts and show top 5
- WP_Query orderby date not working
- WP Query where title begins with a specific letter
- Order by optional meta key?
- Sorting: custom query with orderby meta_value_num THEN by title
- Loop within a loop?
- Order by DESC, ASC in custom WP_Query
- WP_Query and next_posts_link
- WP_Query order by multiple meta keys & fields
- Show posts without term
- Usage of the new “posts_clauses” filter in WordPress 3.1?
- Display products from specific category in shop page
- How to list some posts first in the loop based on post id
- Pagination returns 404 after page 20
- Make loop display posts by alphabetical order
- Using OR conditions in meta_query for query_posts argument
- WP_Query: query posts by ids from array?
- Use WP_Query with have_posts()?
- Secondary Sort (fallback) for WP_Query
- get custom post type by tag
- Custom WP_Query order by post_meta and (author) user_meta
- Sorting posts by custom date fields (non standard date format)
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- get_template_part in for loop
- Query Multiple Post types each with own meta query
- Get array of posts from the current archive page loop
- pre_get_posts with get_posts
- How-to exclude terms from the main query the most performant way?
- Get posts by menu ID
- Pagination with WP_Query is buggy – working for some pages, but not the others