How to get a post in draft status from its slug?
-
I want to include a post in draft status inside another post using a short code.
I tried the following code to retrieve what I want:
$post = &query_posts( array( 'name' => $postslug, 'post_type' => 'any', 'post_status' => 'any' ) );
query_posts finds the right post, then… it deletes it from returned results here.
The very same function using the post ID works perfectly well:
$post = &query_posts( array( 'include' => $postid, 'post_type' => 'any', 'post_status' => 'any' ) );
and returns the post. The ‘include’ parameter accepts IDs, but not slugs.
In fact, query_posts() assumes single posts and pages must follow access restrictions, while it behaves without any security in mind when asking lists of posts, even if the list is made of one entry.
How should I proceed to get the post data with its slug only?
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘How to get a post in draft status from its slug?’ is closed to new replies.