[wp-trac] [WordPress Trac] #49969: Previewing the page designated as "latest posts" shows the frontpage

WordPress Trac noreply at wordpress.org
Tue Apr 21 11:32:20 UTC 2020


#49969: Previewing the page designated as "latest posts" shows the frontpage
-------------------------------+-----------------------------
 Reporter:  zieladam           |      Owner:  (none)
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:
 Severity:  normal             |   Keywords:
  Focuses:                     |
-------------------------------+-----------------------------
 This continues the discussion from
 https://github.com/WordPress/gutenberg/issues/2409

 **The issue**

 * Create two pages (let's call them "My home" and "My posts")
 * Go to customizer and set Homepage to be "My home" and Posts page to "My
 posts"
 * Edit "My posts" in editor mode
 * Press preview
 * Confirm you got "My home" instead of "My posts"

 **The root cause**

 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49969>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list