do_redirect_guess_404_permalink
云策文档标注
概述
do_redirect_guess_404_permalink 是一个 WordPress 过滤器,用于控制是否在 404 请求时尝试猜测重定向 URL。开发者可以通过此过滤器禁用 URL 猜测功能,从而提前返回而不执行重定向。
关键要点
- 这是一个过滤器,允许修改是否尝试猜测 404 请求的重定向 URL。
- 返回 false 值将禁用 URL 猜测,并提前返回而不执行重定向。
- 参数 $do_redirect_guess 是一个布尔值,默认为 true,表示启用猜测。
- 在 WordPress 5.5.0 版本中引入。
- 与 redirect_guess_404_permalink() 函数相关,该函数基于查询变量尝试猜测正确的 URL。
代码示例
if ( false === apply_filters( 'do_redirect_guess_404_permalink', true ) ) {
// 禁用 URL 猜测并提前返回
}
原文内容
Filters whether to attempt to guess a redirect URL for a 404 request.
Description
Returning a false value from the filter will disable the URL guessing and return early without performing a redirect.
Parameters
$do_redirect_guessbool-
Whether to attempt to guess a redirect URL for a 404 request. Default true.
Source
if ( false === apply_filters( 'do_redirect_guess_404_permalink', true ) ) {
Changelog
| Version | Description |
|---|---|
| 5.5.0 | Introduced. |