WordPress.org

Make WordPress Core

Opened 8 months ago

Last modified 8 months ago

#45687 assigned defect (bug)

URL params get lost because of canonical redirect on static front page

Reported by: captain.crash Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 5.0.1
Component: Canonical Keywords: needs-patch
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Please see #25143.

A shortcode that changes its output via (prettified) URL params, i.e. /test/1/.

Use the shortcode on a static front page.

The params are added either with add_rewrite_rule() or add_rewrite_endpoint(), but without adding query vars.
This is basically what the patch in #25143 fixed (3rd param false):

add_rewrite_endpoint( 'test', EP_PERMALINK | EP_ROOT | EP_PAGES, false );

However, the later change on line 175 in changeset [36237] causes a request such as /test/1/ to redirect to / and the shortcode can't work with the param.

On a side note, adding the params as query vars causes the intended static front page to use the posts template because is_home() is true.
I understand that if I don't want URL params to modify the query, I should not register them as query vars (see boonebgorges). However, the template change feels rather wrong to me, too (see mordauk).

Thanks for listening.

Change History (1)

#1 @SergeyBiryukov
8 months ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.