Skip to content

Commit

Permalink
feat: add support for previewing drafts from WP (note: Gutenberg not …
Browse files Browse the repository at this point in the history
  • Loading branch information
claygriffiths committed Feb 4, 2021
1 parent cd42993 commit 76223e6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugins/wpe-headless/includes/replacement/callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ function wpe_headless_post_preview_link( $link, $post ) {
/**
* Add preview and preview ID back to path to support Next.js preview mode
*/
$path = trailingslashit( $path ) . 'preview/' . $preview_id;
if ($post->post_status !== 'publish') {
$path = 'draft/';
} else {
$path = $path ? trailingslashit( $path ) : '';
}

$path .= 'preview/' . $preview_id;

$link = add_query_arg(
array(
Expand Down

0 comments on commit 76223e6

Please sign in to comment.