钩子文档

root_rewrite_rules

💡 云策文档标注

概述

root_rewrite_rules 是一个 WordPress 过滤器,用于修改根级别归档页面的重写规则。它主要影响首页分页和全站文章订阅源(如 /feed/ 和 /feed/atom/)的 URL 结构。

关键要点

  • 这是一个过滤器钩子,允许开发者自定义根级别归档的重写规则。
  • 参数 $root_rewrite 是一个数组,键为正则表达式模式,值为对应的重写规则。
  • 在 WP_Rewrite::rewrite_rules() 方法中调用,用于构建重写匹配和查询。
  • 自 WordPress 1.5.0 版本引入。

📄 原文内容

Filters rewrite rules used for root-level archives.

Description

Likely root-level archives would include pagination rules for the homepage as well as site-wide post feeds (e.g. /feed/, and /feed/atom/).

Parameters

$root_rewritestring[]
Array of root-level rewrite rules, keyed by their regex pattern.

Source

$root_rewrite = apply_filters( 'root_rewrite_rules', $root_rewrite );

Changelog

Version Description
1.5.0 Introduced.