I would like to generate the preview url for a post outside of wordpress admin (wp-admin).
Normally this link is available while editing the post, but I would like to generate it to display on the frontend (a page only accessible by admin).
How can I generate this link using the $post->ID
? Note: preview_post_link
filter is only for changing the url, whereas I need to actually create it.
Turns out it's quite easy using get_preview_post_link()
like:
get_preview_post_link($post = null, $query_args = array(), $preview_link = '' )
This is in wp-includes/link-template.php