headstartwp
headstartwp copied to clipboard
fetchRedirect not working on handleError with Polylang translated slugs
trafficstars
Describe the bug
When having the Polylang integration enabled and slugs for post types are translated, the fetchRedirect pathname is not matching the translated slug in handleError, therefore a redirect added for a different locale in WP is not detected.
Steps to Reproduce
- Create custom post type., slug example 'programmes'
- Add translation to the post type slug in polylang, for example PT 'programas'
- Add rewrite in middleware so NextJS knows
programastranslated path isprogrammes/ - Add a redirect from from WP with Safe Redirect Manager from '/pt/programas/foo' that returns 404 to an existing page
- Within handleError function pathname is the ctx resolvedUrl which is programmes/foo
- See redirect not working.
- Inside handleError to test, hardcode pathname in fetchRedirect to '/pt/programas/foo' and see redirect working.
Screenshots, screen recording, code snippet
No response
Environment information
WP 6.4.3 Safe Redirect Manager 2.1.0 Polylang Pro 3.3.2 @headstartwp/core 1.1.2 @headstartwp/next 1.1.5
WordPress information
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
I think we need better support for Polylang translated slugs featured. I'll look into how this could be better supported in general.
@lucymtc was your fix essentially skip using ctx.resovledUrl at all even when using getStaticProps?