pre_redirect_guess_404_permalink
云策文档标注
概述
pre_redirect_guess_404_permalink 是一个 WordPress 过滤器钩子,用于在 404 请求时短路 URL 猜测重定向过程。开发者可以通过此钩子自定义或阻止默认的 URL 猜测行为。
关键要点
- 此钩子允许开发者通过返回非 null 值来短路 redirect_guess_404_permalink() 函数的 URL 猜测逻辑。
- 参数 $pre 控制是否短路,默认 null 表示继续猜测,返回字符串或 false 可自定义重定向或阻止重定向。
- 钩子自 WordPress 5.5.0 版本引入,常用于优化 404 页面处理或实现自定义重定向策略。
代码示例
$pre = apply_filters( 'pre_redirect_guess_404_permalink', null );
原文内容
Short-circuits the redirect URL guessing for 404 requests.
Description
Returning a non-null value from the filter will effectively short-circuit the URL guessing, returning the passed value instead.
Parameters
$prenull|string|false-
Whether to short-circuit guessing the redirect for a 404.
Default null to continue with the URL guessing.
Source
$pre = apply_filters( 'pre_redirect_guess_404_permalink', null );
Changelog
| Version | Description |
|---|---|
| 5.5.0 | Introduced. |