Your first example also needs the orderby
parameter set, otherwise it defaults to standard date order:
$my_query = new WP_Query(
array(
'post_type' => 'slider',
'post__in' => $posts,
'orderby' => 'post__in'
)
);
Related Posts:
- why ignore_sticky_posts in sticky post query
- get custom post type by tag
- Does tax_query really beats meta_query in all situations?
- WP_Query by post ID doesn’t work if post is in custom post_status
- Using WP_Query To Get Posts Randomly From today
- Tracing the life of a query
- WP_Query orderby taxonomy term value (numeric)
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- WP Query and order by particular specified IDs
- Get the post permalink within the loop but without additional DB query
- Display revision if post status is pending
- Meta query field order together with post_date order causes posts without the meta field to be unordered
- How To Remove/hide some specific categories from two different categories widget from sidebar
- WP Query search for attachments and their exact title
- How to add another parameters to WP_Query?
- Display link to taxonomy archive only if it has posts with certain custom field values
- WP_Query compare with dynamic values
- WP Rest API max limit include parameter?
- How to display posts month by month?
- Programmatically set ‘meta_query’ for filter
- Display posts with date wordpress default
- WP Query Exclude and Start by Menu Order Offset
- Pagination is broken and I need help fixing it
- Query total number of posts
- Category attribute not working in custom shortcode
- WP_Query Excluding pages with Order is 0
- How to display a posts 1 year ago with custom WP_Query loop?
- Check on which page specific result exist
- WC displaying products from category
- Show all post for a given category
- Loop returning only 1 result
- WP_Query create html structure
- How is WP_Query parsed to determine which template to request?
- Fetch posts that match term slug first two letters (wp query)
- pagination with numbers for WP_User_Query
- How does one perform a sub query with different post types
- Stuck in the query loop
- Query Page Content From Theme Options?
- Filter wordpress post categories with jquery/ajax and pagination?
- Taxonomy order exception for specific term
- How to Create a Random List of Child Pages
- How to display the featured image for each post?
- How do I amend wp_query before it is run/executed?
- Post Thumbnail URL isn’t pulling into the background of div
- Is there a way to make this kind of loop shorter and nicer?
- WP Query ordering on a meta field for posts with a date in the future not ordering by datetime
- Merge 2 custom post type posts and taxonomy terms and sort ascending
- Pagination on template page for custom query redirecting to index.php
- how to get Nearby zipcode
- Exclude authors IDs from WP_Query
- Reload Query Loop When FacetWP Uncheck [closed]
- WP Query Compare cutting off last 2 dates
- get_page meta query not working, maybe a bug?
- Exec wp query in slow motion to avoid memory error?
- Wpdb->query result show 1 but is not an integer
- Remove post type filter added by the plugin in the final query
- How to get more data of a post by wp_query
- Query of all pages, including children, ordered by meta key
- WP_User_Query orderby meta_val_num
- Query Taxonomy By Page Title
- WP_Query custom order and pagination
- specific post is not excluded from the loop
- Unable to paginate a custom page query
- How to change the default post type over the loop?
- Why is the value zero going in my custom database table?
- How to WP Query custom multiple custom taxonomies?
- Determine if ID is page or post and query the ID
- get_the_terms has strange result since version 6.0
- How to display posts from custom post type category(custom Taxonomy) wise?
- Search filter between promo and exact price
- How to allow a variable with “/” in wordpress url
- Bootstrap grid while loop
- How to get taxonomy image attached to a Post Type WordPress
- How to display a post(by id) along with css in a page?
- search multiple keywords with wp_query using one query
- Order posts by tags count?
- Pre get posts sort by meta key returns no results if meta key does not exist
- Search has query that will return no results
- remove_action – pre_get_posts – does not restore original query
- meta_query with relation = AND not working as expected when combining EQUALS with NOT EQUALS
- How to define a custom hierarchy for terms?
- WP_User_Query not searching numbers?
- Some doubts about how the main query and the custom query works in this custom theme?
- orderby in WP_QUERY – Use the order from the Dashboard
- Escaping WP_Query tax_query when term has special character(s)
- Mathematical operations on custom field values? (updated)
- Trying to Exclude Sticky Posts From date_query
- Load 3 posts in flexslider slide [closed]
- Issue with WP_Query (need a array of selected ID’s)
- Get post closest to today
- Multiple loop for “featured” items returns wrong posts
- Get WP_Query query after execution?
- Pagination in custom query not working [duplicate]
- query_posts problem – need help
- $query_args for loop to only get posts from “current category”?
- 294 Queries on Mainpage of WordPress
- Pagination on custom post type not working
- How do I subquery with custom meta fields?
- Show number of posts AND number on current page (cannot make it work)
- Advanced Search – Is this possible?