admin管理员组

文章数量:1122846

When requesting short urls they are redirected to their matching permalink, for instances :

shortlink permalink
/?cat=category_id /category_base/category_slug
/?p=post_or_page_id /custom_structure/post_or_page_slug/
/?author=account_id /author/account_slug

What's the part of the code handling this and is it customizable through hooks ?

When requesting short urls they are redirected to their matching permalink, for instances :

shortlink permalink
/?cat=category_id /category_base/category_slug
/?p=post_or_page_id /custom_structure/post_or_page_slug/
/?author=account_id /author/account_slug

What's the part of the code handling this and is it customizable through hooks ?

Share Improve this question edited Apr 21, 2024 at 14:47 challet asked Apr 21, 2024 at 13:32 challetchallet 1114 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

That's handled by the redirect_canonical function, set up as a default template_redirect filter.

So it can be customized either by :

  • a template_redirect filter, with a priority value lower than 10, so it runs before the redirect_canonical function (which will eventually skip the next filters by making a redirect).
  • a redirect_canonical filter called by the function of the same name

本文标签: Where does the redirect from shortlink to permalink happen