I have a draft post with the author set to 5. User #5 is trying to view that draft on the front end using a WP_Query with the following arguments:
array {
["name"]=> "example-52f00a8ba19f4"
["post_status"]=> array {
[0]=> "draft"
[1]=> "private"
}
["post_type"]=> "customlisting"
["posts_per_page"]=> 1
["author"]=> 5
}
The user trying to view this is user #5. They are trying to view their own draft post, so that they can publish it... (on the front end)
The SQL query that is available in $wp_query->request
does in fact return the listing (screenshot from HeidiSQL). But it does not appear in $wp_query->posts
, and it seems WP_Query is removing it after the actual SQL query.
How can I prevent WP_Query from removing this? I don't know where to look. I don't know why it's happening either :/
Update: It seems the query only fails if searching by post name. It works by post ID (post__in, rather).