You have to use post__in
(double underscore) argument, instead of post_in
:
echo print_r($rel); // Array ( [0] => 63 [1] => 87 )
$args = array(
'post_type' => array( 'post' ),
'orderby' => 'ASC',
'post__in' => $rel
);
$loop = new WP_Query( $args );
If you are unsure why an argument is not working, copy it’s key name from manual and past it into you snippet.
Related Posts:
- WP_Query vs get_posts
- Usage of the new “posts_clauses” filter in WordPress 3.1?
- pre_get_posts with get_posts
- Query Custom Meta Value with Increment
- Identify which loop you are hooking into; primary or secondary?
- Transient pagination not working properly
- meta_query on a date range using an array of values
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- Undefined WP_Query::has_posts()?
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- if/else on custom query gives 200 OK when condition not met?
- Order by empty custom field
- Check if loop has any categories?
- How to get list of posts from permalinks?
- Is_single() conditional tag returns null in query
- Transient api Caches confused
- Include current post into loop
- Should I reset $wp_query?
- How to filter query loop block with a search string from the query parameters
- I am officially missing something about transient posts
- WP_Query & Duplicate entries
- how to show more than 1 post into three columns query
- Ordering Posts by parent category, name ascending
- WP_Query secondary query failing
- Loop through multiple custom fields with increasing number
- meta_query dates from an array
- Main loop querying current template’s info only in custom category archive pages, not my posts
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- Can I force WP_Query to return no results?
- WP_Query and next_posts_link
- Order posts by ID in the given order
- How-to exclude terms from the main query the most performant way?
- Pagination with WP_Query is buggy – working for some pages, but not the others
- Get the number of posts from the current page results
- When should you use wp_reset_postdata vs wp_reset_query?
- Ajax Infinite Scroll In Custom WP_Query Loop Not Working
- How to change a custom query into a standard loop?
- Injecting content with $wp_query->current_post restarts from zero on paged pages. How to inject content after X posts, regardless of pagination?
- wordpress query in header won’t reset and corrupts other loops
- Custom Post order for homepage
- Get image of latest post from taxonomies/categories
- Page navigation doesn’t show when query category
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- 2 loops on page – one with orderby rand second orderby date
- Is it possible to dynamically get queried term AND taxonomy?
- Pull post meta with post_query?
- How to access a query twice in different template files?
- How to use WP_Query to display many posts?
- Counter problem, infinite loop when post_per_page equals X
- Five posts from a category in footer
- Add quicklink to in the Admin posts page where I can query by a meta_key
- How to get all unique categories for posts in loop?
- Using the_post_thumbnail resets current loop item ID
- How to use the query hook/filter?
- No results found from a $wpdb->get_results() query when trying to join more than one meta key query
- New WP_Query loop in admin causes problems
- Need to convert string of term ids into comma separated integers for use in an arguments array
- How do I get my custom query to work with search results after the first page?
- Issue with front page navigation after upgrading to 3.4
- Exclude recently updated post from custom WP_Query using multiple loops
- get_posts output always same post
- difference between querying database and using the loop
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Loop increase in while loop not working
- posts archive page – closing WP_Query loop correctly [closed]
- Yoast primary category query modification
- AJAX Breaking Offset Argument In WP Query
- Continue or break the while loop
- Loop posts based on permalink term
- Write WP Query that selects posts that are part of the same two categories
- Does putting queries within loops cause an issue on WordPress?
- Function using get_posts() with tax_query not working when called from functions.php
- Include one page/post into query which is already returning posts
- Why doesn’t my WP Meta Query return any results?
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- How to make the ‘request’ filter work?
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Filter products on category AND tag
- How do I stop the same post showing multiple times in a archive?
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- How to get meta key list efficiently?
- Why pagination is not working with tax_query param?
- how to get custom attachment url?
- Query by meta value (add a dropdown of all values)
- Calling a function with WP_Query only ever brings the first result
- query_posts() doesn’t seem to be called in my page
- Query posts in current category but not attachment format
- Create multiple sections for all categories and then queries all the posts for each of those categories
- wp_query – Modify $query to include duplicate content
- Optimising specific Query with ACF meta objects
- How to get several fields from wp_query?
- Pagination not working with WP_Query (creates links but no page)
- Next / previous posts link doesn’t show up with Posts 2 Posts
- Query custom post type by date field only working when two posts match the query
- Divide WP_Query posts by date & post type
- Query Posts by date range with fixed beginning and end
- query by meta value then date and not empty meta value
- New WordPress WP Query using posts from certain categories
- Carousel Loop only duplicating
- How to show featured post first, then separate loop for other posts