Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Preview links don't work from Gutenberg for drafts #536

Closed
iakshay opened this issue Jun 26, 2021 · 0 comments · Fixed by WebDevStudios/wds-headless-wordpress#48
Closed

Comments

@iakshay
Copy link

iakshay commented Jun 26, 2021

Describe the bug
Preview links don't work from Gutenberg for drafts –

image

This seems to be a problem in upstream WordPress/gutenberg#13998. Not sure, whats a good short-term solution for this. Would be nice if this can be fixed.

I was thinking something like this might work in index.php -

if (is_user_logged_in() && $_GET['p'] && $_GET['preview']) {
    $post = get_post($_GET['p']);
    header( 'Location:' . get_preview_post_link($post), true, 303 );    
} else {
    header( 'Location:' . HEADLESS_FRONTEND_URL, true, 303 );
}

To Reproduce
Steps to reproduce the behavior:

  1. Create a new post from admin UI, type in the title and content.
  2. Click preview as in the screenshot above, the link points to Wordpress rather than NextJS website.

Expected behavior
The preview link points to Wordpress and redirects to NextJS home page rather than post preview.

Screenshots
Attached above

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant