Table of Contents block: fix links when in archive loop or when using "Plain" permalink structure.#29394
Conversation
|
Size Change: 0 B Total Size: 1.4 MB ℹ️ View Unchanged
|
7a32b71 to
b9ba53a
Compare
|
Thanks @ZebulanStanphill ! Looking forward to the feature. |
|
Hi Zeb @ZebulanStanphill . |
|
@paaljoachim Good idea. I've added testing instructions to PR description. |
|
Hey Zeb. Using WordPress 5.7 RC2. Switched permalinks to plain links. Heading-Page-Breaks.mp4Nicely done. This works fine! --> Sidetrack. |
paaljoachim
left a comment
There was a problem hiding this comment.
I can approve the PR based on the working functionality seen through the user interface. Going through the code I will need to leave up to someone else.
|
@paaljoachim To be clear, you should also test to see if the links still work when viewing the post from another page, e.g. the home page's default blog feed. (Some themes will use HTML-stripped summaries, but Twenty Fourteen, like most of the older default themes, displays the entirety of the posts on the home page.) Or maybe you already tested that, but it wasn't clear from your comment. (I already tested it, and it worked, but it's always nice to get confirmation.)
This is a pretty common issue caused by |
Offtopic; There's a CSS property for this: https://www.caniuse.com/mdn-css_properties_scroll-margin-top |
There was a problem hiding this comment.
Almost! I'm seeing a 301 redirect when a post does not have multiple parts. Everything else tests very well.
The url creation here is a good candidate for unit tests to document the cases for permalink choice and multipart posts. I'm fine if it's a follow up though since it might take some work to set up.
redirect.mp4
This also fixes links for posts using the default "Plain" permalink structure.
b9ba53a to
5e84309
Compare
Yeah, unit tests would be neat. I'll try and create some in another PR if no one else wants to. |
There was a problem hiding this comment.
Nice work ✨ I verified that this works well for multipart and single page posts, and am no longer seeing the 301.
Yeah, unit tests would be neat. I'll try and create some in another PR if no one else wants to.
That'd be lovely to follow up on @ZebulanStanphill

Description
This PR fixes two bugs with the Table of Contents block:
https://example.com/?p=7/./2#id, which isn't a valid URL. (The proper one would behttps://example.com/?p=7&page=2#id.) This is fixed by switching over to using thepagequery param to choose which page to go to. This should work with any permalink structure, since on sites with slug-based permalink structures,https://example.com/post-slug?page=2#idwill automatically redirect tohttps://example.com/post-slug/2#id.Special thanks to @asafm7 for pointing out the first bug, which led me to discover the second while trying to fix it.
Testing instructions
YOUR_SITE/wp-admin/options-permalink.php.Checklist: