WordPress query for preview?

I am looking for an equivalent of getting a page/post with WP Query or get_posts e.g.:

$args=array(                        
  'category' => 1,
  'name' => 'my-page',
  'post_type' => 'page',
  'post_status' => 'publish',
  'numberposts' => 1
);
$my_post = get_posts($args);

but I want this for a preview, only thing I have are the preview GET parameters:

Read More
?preview=true&preview_id=5&preview_nonce=b0d41a7fdb

The preview_id is actually the ID of the created post, not the id of the preview.

Any ideas?

Related posts

Leave a Reply

1 comment

  1. So I eventually found a possible answer – this should retrieve the latest preview or “revision”:

    $args = array(
      'post_status' => 'any',
      'post_parent' => intval($_GET['preview_id']),
      'post_type' => 'revision',
      'sort_column' => 'ID',
      'sort_order' => 'desc',
      'posts_per_page' => 1
    );
    $my_post = get_posts($args);