钩子文档

blog_redirect_404

💡 云策文档标注

概述

blog_redirect_404 是一个 WordPress 过滤器,用于修改主站点上 404 错误的重定向 URL。该过滤器仅在定义了 NOBLOGREDIRECT 常量时生效。

关键要点

  • 过滤器名称:blog_redirect_404
  • 参数:$no_blog_redirect(字符串类型),表示 NOBLOGREDIRECT 常量定义的原始重定向 URL
  • 使用场景:在 maybe_redirect_404() 函数中调用,用于校正当 NOBLOGREDIRECT 定义时的 404 重定向
  • 引入版本:WordPress 3.0.0

代码示例

$destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT );

📄 原文内容

Filters the redirect URL for 404s on the main site.

Description

The filter is only evaluated if the NOBLOGREDIRECT constant is defined.

Parameters

$no_blog_redirectstring
The redirect URL defined in NOBLOGREDIRECT.

Source

$destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT );

Changelog

Version Description
3.0.0 Introduced.