Use $wpdb->get_col. It will return a one-dimensional array that you can use in post__in
$allposts = $wpdb->get_col("SELECT `music_id` FROM `custom_table` ORDER BY id DESC LIMIT 5");
Related Posts:
- Use Transient API to cache queries for all posts in all categories?
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- What kind of object type is WP_Query?
- How can I save an array from a random post sequence for later use?
- Getting an array out of WPQuery
- assign 2 $args to one wp_query
- WP Meta Query for some meta (array) values
- meta_query with array as value
- Show list of authors with latest post NOT older than a month
- Dynamically Override Fancy Title – Part II
- Placing a div or img in between a post array using WP Query [closed]
- Show one post per author and limit query to 8 posts
- How can i get the last post from wp multisite?
- wp_get_post_terms of cpt but not duplicates if they are used more than once in the loop
- Count total number of post in foreach loop
- How add a custom posttype name using ACF field to a query post array
- Can an array be used as a meta_query value?
- How do I dynamically generate args for wp_query?
- How can I get an array of all IDs from the current queried object?
- How can I pick a single post from the latest 3?
- WP Query for variable taxonomies
- Minimize database queries to user tables?
- (Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array
- only delete post within query / for each statement (front end)
- Adding an array from a query string to a WP meta_query
- How to use $query->set with post__in?
- Weird orderby => post__in issue
- How to list custom fields as headers and list all pages sharing that custom field under it?
- Exclude posts based on meta value
- Warning: Invalid argument supplied for foreach(). when creating a WP_query
- Stuck in the query loop
- Query all posts if multiple meta key don’t exist
- Get posts by list of post IDs ordered by those IDs?
- Redirect to another page using contact form 7? [closed]
- Removing duplicate values between two wordpress queries
- Include current post into loop
- Assign custom parameter to each post in query
- Combine results of multiple WP_Query to resemble single WP_Query
- Does meta_value (array) work with ‘orderby’?
- search serialised meta_value for date value?
- Combine 2 arrays in a query parameter
- Getting posts to exclude from array
- Get all posts as an array ID => Name
- extract serialized array to use for wp-query
- How can I comment comma-separated array values?
- How do I add a relation parameter to my filter query?
- construct complex queries with WP User Query
- How can I split my query result in 2 arrays?
- array_rand not working correctly?
- Get a list of ACF Repeater-Fields as array
- Order a WP_Query by meta value where the value is an array
- WP_Query with page_ids in arguments without a result
- Related Posts Excluding Certain Categories
- Query using string from custom field as array value
- Multiple meta query from array
- Category based on post id
- How to get specific string in explode array?
- How to avoid filling up an array each time I run a WP_query?
- How can i show pagenavi in my author.php?
- Remove from array in WP_Query loop
- Using multiple variables to assign categories to an array
- meta_query returning excluded result
- Sending simple variable on single page to WP JSON
- Combine relationship posts with existing wp_query
- in_array not working on dev server but works on localhost
- Counting instances of words in the results of a post query
- sanitize_post() is not sanitizing Post Object
- Retrieve all custom field values of a specific custom field metakey as an array, inside WP_Query
- WP Query by 4 different taxonomies
- Trouble with serialized metadata
- What code to use in an array to call the current sub-category?
- WP_User_Query Orderby Not Working
- Loop through array of pages
- Combine multiple queries, array_unique returns nothing
- Repeat array inside array through while loop
- Sorting Posts by Taxonomy thats not within the query’s $args
- Related Post by Tags Code
- date_query problem
- WP_Query: Meta_Query with serialized value (or a workaround)
- how to query for meta_value have array
- wp_query – Modify $query to include duplicate content
- Iterate through ID’s in loop
- How to get several fields from wp_query?
- How to sort a WP_Query array by post_name after an array_merge();
- Issue with WP_Query (need a array of selected ID’s)
- WordPress WP_Query Array Custom search via taxonomies
- Custom post type archive organized by category
- WP Query posts__in not working with array
- Sort Posts with custom meta key by default which is currently set as optional
- Dynamically name array in WordPress loop – add/get values
- Dynamically create array from page title
- WordPress Query Returning Every Post
- Creating Custom Query
- How do I have multiple metaqueries inside one wordpress query
- I want to place a post before all others from an ACF boleen field
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- wp_query, calculate with two dates when ‘key’ is text format
- WordPress Blog Posts with Pagination inside a Page/Post
- Redux option doensn’t seem when include from functions.php
- query only direct child and sub-terms of a current term archive