Use orderby post__in
$loop = new WP_Query(
array(
'post_type' => 'product',
'post__in' => $posts,
'paged' => $paged,
'posts_per_page' => 5,
'orderby' => 'post__in'
)
);
Remember it is only available from version 3.5
Related Posts:
- How do I reorder (pop and push) items from WP_Query?
- Reverse chronology of post listing
- WP_Query orderby not working with meta_value_num and menu_order
- How can I sort posts by the date and a custom meta field?
- How to order posts by meta_value and title
- how to get post order by post id wp_query?
- Need to know custom code to display random and most viewed posts in wordpress posts and pages
- query posts with selected post ids first
- WP_Query sort by meta_value_num or date
- Random order of the 5 most popular posts
- My custom query is displaying random posts in random order
- Order by ‘s’ using WP_Query()
- How to Change Order of Posts in Admin?
- Get first post from wp_query
- Sort posts by popularity/page views
- Accessing the post content with WP_Query
- How to query serialized array by comparing greater than (>=)?
- How to sort posts by last name (2nd word) on ONE category only?
- Query posts distinct authors
- How to get previous 10 days post from a specific date – WP Query
- Specific loop in Shortcode
- Sort posts by activity date
- prevent showing posts of an specific category in admin posts section
- How to output comments number of a post per day?
- Search widget breaks when using multiple loops?
- How to change bulk post status
- If specific user role then sticky post
- Display posts with comments closed, with pagination?
- post re-order on my site
- WP Query related posts by current page Tag ID
- I want to query posts in monthly basis
- Custom WP_QUERY $args
- WP_Query get posts from custom posts by category
- Accessing post->ID outside of the loop for listing child pages
- Limiting the number of posts in WP_Query leads to unexpected result
- List posts in a given category
- Reset Popular post query?
- Query Posts multiple conditions
- Why orderby=”date” does not support manually changed posts?
- Future post ID not showing
- Search by post title and content in wp_query without order
- How to do set post permalinks using 6 digit random unique function?
- Any way for get_next_post() to use the actual post order instead of publish order?
- How safe is renovating $wp_query when doing WP_Query pagination in Page Template
- Query Posts With Over 1000 Views
- List authors with the last post title and order by last post date
- Adding a blog archive with pagination using WP_Query
- How to get Tags with specific post id
- Order posts alphabetically: how to set order=asc in mysql query?
- WordPress query_posts by tag doesn’t work anymore(?)
- Ignore latest two posts
- Print out last 3 blogposts
- Why posts array is empty?
- How can I add a box to edit Order on a regular post?
- How to group only VISIBLE posts? [closed]
- Shortcode with ‘year’ parameter
- On what hook can I get the queried object’s final state?
- How can I insert a new markup element after 4 posts automatically? [closed]
- how to handle the loop using filling bootstrap grid structure?
- Get all custom posts with a certain taxonomy
- Link to date_query results in WordPress
- When WP_Query only returns 1 post, how do I automatically redirect to that post?
- Limiting post list by taxonomy
- How to display WP Query filters?
- Finding a post’s slug
- Order posts by date
- Optimal WP Web App Backend for mobile app development
- How do I display main query posts in random order using add_filter
- Display Parent-Child Posts in specific order by comparing IDs in array
- Function is printing twice – any suggestions?
- SEARCH QUERIES – REVERSE OUTPUT
- How to use two query result together in one loop
- show loop id post , only first id can read
- How to get value of a selected option from select tag and use it in WP_query to filter posts?
- Counting Posts by Category
- show image gallery in archives or category page
- Page with Category Returning 1
- filter posts based on menu_order
- Change archive results based on GET request
- wp_query args with relation
- Wp_query loop is not working as it should
- Show all posts from the tags without having to set all of them
- Creating Ordered Query using Meta_key
- Is there a global page/post/product/anything ID?
- WP Query between posts custom fields [duplicate]
- Retrieve latest post by multiple categories with ID
- Update Post with Modified Data
- Can’t get pagination to work
- How to Include a common category in a custom Category Search
- wp_query select if have comments
- Last three posts not being put in order by date. How to fix this?
- wp_query posts sorting doesn’t work
- custom sort posts in archive/taxanomy page
- how to print loops for odd in 1st column and even in 2nd column in wordpress [closed]
- Trying to create shortcode listing custom posts, but formating not being included
- Show Title/Date/Excerpt of first post & only Title for rest in Query [duplicate]
- Get posts after calculating meta key
- Next and Previous buttons are not showing on home page for post
- How do I get content of custom post type through post ID
- How to speed up WP_Posts_List_Table __construct() Query on a wordpress website with over 1 million posts?