You can just 'post_status' => 'any'
.
Here is the completed code.
global $wp_query;
$ids = array(130,132);
$args = array(
'post_status' => 'any',
// 'post_status' => 'any', // same output
'post__in' => $ids,
'post_type' => 'alpha'
);
$q = new WP_Query($args);
foreach ($q->posts as $post) {
echo $post->id;
}
Official docs on post_status
option
https://developer.wordpress.org/reference/classes/wp_query/#status-parameters
Related Posts:
- WP_Query by post ID doesn’t work if post is in custom post_status
- How to Get All Posts but the Private ones?
- How can I style future post?
- Get images only if parent status is publish
- How to display future posts – modified query still yields 404
- Can’t get drafts with WP_Query using post_status parameter
- Wp_query Add specific pending posts
- Show scheduled posts in main loop but not in WP_Query?
- wp_query ignoring custom post_status
- Does the WP_Query ‘private’ argument for post status only apply to privately published content?
- Why won’t draft listings appear for non-admins?
- WordPress post_status and meta_query
- Give attachments an archive page, and exclude unattached ones
- Loop within a loop?
- WP_Comment_Query pagination, delving into the unknown
- Sort posts by category name and title
- Getting all user metadata from user
- ajax category filter
- Display posts the match taxonomy term linked from wp_list_categoies?
- How to get posts in different language from WPML Plugin [closed]
- Limit WP_Query to only X results (total, not per page)
- How to disable main query?
- Use post__in and post__not_in together?
- WP_Query on different site in a multisite setup
- how to retrieve specific product attribute value in an sql query?
- How to user WP_Query to lower the number of queries
- Compile two queries to one set of results?
- how do i combine keyword search and taxonomy in a WP_query $args array Worpresss [closed]
- Only display authors who have posts
- How to search by a post and a category name on wordpress at the same time?
- How to retrieve current page WP_Query arguments?
- How can I get an array of all IDs from the current queried object?
- Query Custom Post Type Order By Taxonomy Field
- Query post from all category with same tag on 1 pages
- How to use filter hook “the_posts” with a function that refers to $this?
- Multiple loops without repeating content
- WP_Query, pre_get_posts and offset
- Sort query by author: 1 author, then others
- add_actions called from functions.php not returning good values
- Multiple Search Terms WP_Query
- Show posts from a custom taxonomy on a page
- Suggestions on making this query/code more performant
- How to return a 404 when custom query matches nothing?
- Should wp_query automatic meta and term cache priming be used in an enviroment with an object caching
- wp_query with custom post type only returning last posted
- Display custom tags on pages that have a specific page parent
- Slow WP_Query with ‘OR’ on meta_query
- How to filter a query by multiple meta keys and order by other meta keys
- Custom query: Get all posts that are from a certain category?
- Transient api Caches confused
- How can I override one post and make it display content for another post?
- Exclude parent with child pages from WP_Query
- Co-authors list of all posts
- Query Posts by Tag and exclude
- get_posts always returning the same number of posts = 5
- How to import a WP backup website into another WordPress hosting?
- How to apply a function to a metadata value before launch a WP Query?
- Pagination for custom loop on custom page template is not displaying anything
- Display posts by tag
- Overriding $wp_query on a template
- How to use ‘WP_Query’ or ‘query_posts’ to display content in a descending order
- How to display specific ids of posts using wp_query?
- How can i show pagenavi in my author.php?
- Randomly select one of last 3 posts
- Query multiple meta key values for template
- Using WP_Query with multiple loops on one page in search.php
- Order by post meta not working with pre_get_posts filter
- Searching not only by post name but also category
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- is_user_logged_in not working from WP-API (wp-json)
- WordPress private post won’t display to other admins
- Only show tag with the same id as the post
- Search Exact on WordPress – Relevannsi Solution Not Working
- ACF: How can I publish values of ACF fields in a loop while using wp_query?
- Sort by price wpdb
- Posts per Page not working
- WP_Query random ordering not working since 5.4
- Show a message if there are no active posts in category
- Get authors list and sort them by recent posts
- How to get the latest post list (of the parent custom custom type)
- Problem with my loops
- next_posts_link not visible on first page
- Pagination not working in custom loop WP_Query
- Multiple wpostmeta.meta_key
- Own query vars are not displayed
- Show full category tree for a year with all post titles?
- Trying to use “Medium” featured image for custom post type on home page
- Modify query to exclude certain ids and certain parents and its corresponding children
- Filter posts/pages by user_role array
- WP_Query with meta_value_num and meta_query not paged correctly
- I need value of saved meta to display next to the post it is associated with
- Post Query not working after updating to 4.1
- Cannot order by in WP_Query
- Search Query that Includes Custom Table
- Pagination with WP_Query not working
- new WP_Query based on average values of meta fields
- Can’t seem to get an else statement correct? [closed]
- query_vars category_name only display one catgory out of multiple categories
- Incorrect posts displayed on category page
- Display post format post in the sidebar