Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Previewing the page designated as "latest posts" shows to the frontpage. #2409

Closed
joyously opened this issue Aug 14, 2017 · 12 comments
Closed
Labels
[Feature] Saving Related to saving functionality [Type] Bug An existing feature does not function as intended

Comments

@joyously
Copy link

joyously commented Aug 14, 2017

Discussion for Trac ticket https://core.trac.wordpress.org/ticket/34005
What should happen when you edit the Page designated as Latest Posts?

(Edited to add reproducing steps below)
To reproduce:

  • Create two pages (let's call them "Front" and "Blog")
  • Set Homepage to "Front" and Posts page to "Blog"
  • Edit page 2 in editor mode
  • Press preview
  • Confirm you got Front instead of Blog
@karmatosed
Copy link
Member

For now, this I think needs closing as not something we should tackle in v1 of Gutenberg. It is worthy of consideration as we iterate.

@joyously
Copy link
Author

This issue needs to be reopened.
In the below test, I have assigned "a Blog Page" to be the page for Latest Posts, and "Page with Comments" to be the Home page.
When I edit the Blog Page, it shows the content as expected. But clicking on the Preview button shows the Page with Comments Home page, although the menu styling indicates that the Blog Page is the current page.
Tested with WP 5.3 (also got same result with GB 6.8 and GB 7.0).
edit-latest-posts-page-2019-11-29 11-10

@ryanwelcher ryanwelcher reopened this Nov 29, 2019
@melchoyce
Copy link
Contributor

Weirdly, when I try to open my Posts Page in the editor, it loads it in the Classic Editor instead of Gutenberg.

@talldan talldan added the [Status] Needs More Info Follow-up required in order to be actionable. label Dec 16, 2019
@talldan
Copy link
Contributor

talldan commented Dec 16, 2019

@joyously Please could you update the title and description of this ticket? If you can provide steps for reproduction that would be appreciated.

@youknowriad
Copy link
Contributor

youknowriad commented Jan 13, 2020

Closing. Let's reopen when this #2409 (comment) gets addressed.

@joyously
Copy link
Author

Hey, I don't see the point in closing because you want a different title.
There is a problem here, and it's not fixed, so this should remain open. I clearly show what happens. What more do you need?

@youknowriad
Copy link
Contributor

It's not closed because it needs a different title, it's closed because contributors didn't understand the issue and how to reproduce making the action non-actionable.

@khacoder
Copy link

So I am getting a very similar problem to joyously.
My page settings are Homepage: Frontpage and Posts page: Blog.
When in editor mode on the Blog page and I press Preview I get the Front Page and not the blog index (blog posts). So I just wanted to confirm that there is definitely a problem.

I have WordPress 5.3.2 installed. This happens with and without the Gutenberg plugin installed.

@youknowriad
Copy link
Contributor

I tried again and I was actually able to replicate the issue with these steps. #2409 (comment)

@youknowriad youknowriad reopened this Jan 16, 2020
@youknowriad youknowriad added [Feature] Saving Related to saving functionality [Type] Bug An existing feature does not function as intended and removed [Status] Needs More Info Follow-up required in order to be actionable. labels Jan 16, 2020
@youknowriad youknowriad changed the title What should happen when you edit the Page designated as Latest Posts? Previewing the page designated as "latest posts" shows to the frontpage. Jan 16, 2020
@adamziel
Copy link
Contributor

I tracked down why the preview shows the front page and it's a core issue. After clicking "Open preview in new tab" while editing posts page, Gutenberg redirects to a preview URL like this one:

https://mywpsite.com/?page_id=5&preview_id=5&preview_nonce=12bd60d6f4&preview=true

When you visit that URL, WordPress will load the front page instead of the posts page. This is because class-wp-query.php assumes that posts page is also the front page:

https://github.com/WordPress/WordPress/blob/b4373fafe9b87f75bf9d65e808be8049510dff8b/wp-includes/class-wp-query.php#L1032

Then, when rendering a preview, it substitutes the page_id that was requested with the value of get_option( 'page_on_front' ):

https://github.com/WordPress/WordPress/blob/b4373fafe9b87f75bf9d65e808be8049510dff8b/wp-includes/class-wp-query.php#L1904

If I remove the preview parameters and leave only ?page_id=5, it displays the correct page. It could be an okay-ish workaround since marking posts page as a draft or private doesn't actually prevent unauthenticated users from viewing it. Still, I think we should be really addressing the root cause in the core - I am going to close this one and fill a core ticket.

@adamziel
Copy link
Contributor

The core ticket is available here: https://core.trac.wordpress.org/ticket/49969

@joyously
Copy link
Author

I think you all sidetracked my original question for this issue, which was "What should the editor show when editing the Page designated as Latest Posts?"
Because the editor is WYSIWYG, should it show the actual contents of the Page (which is the current action) or should it show what is on the front end (which is the Preview-which happens to be wrong)? Perhaps this case is one way to enter into the Full Site Editor to be consistent, but that means there would be no way to edit the Page in preparation to switch it back to being a normal page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Saving Related to saving functionality [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

8 participants