Preview url not working outside wp-admin

Question

So, I created a link in the frontend which allows the user to preview their post. However, when I click on it, it takes me to the published post instead of previewing the changes I made.
Here is what I wrote:

<a href="<?php echo get_preview_post_link($post->ID) ?>" target="wp-preview-<?php echo $post->ID ?>" id="post-preview"> Preview </a>

If I go into wp-admin and preview the post, it works fine.

0
Mike Bensen 1 month 0 Answers 10 views 0

Leave an answer