函数原型
add_rewrite_rule( string $regex, string|array $query, string $after = ‘bottom’ )
函数描述
Adds a rewrite rule that transforms a URL structure to a set of query vars.
是否弃用
未弃用
函数参数
-
$regex
string
Required - Regular expression to match request against.
-
$query
string|array
Required - The corresponding query vars for this rewrite rule.
-
$after
string
Optional - Priority of the new rule. Accepts
'top'or'bottom'. Default'bottom'.Default:
'bottom'
函数返回值
无
函数位置
File: wp-includes/rewrite.php.
函数源码
function add_rewrite_rule( $regex, $query, $after = 'bottom' ) {
global $wp_rewrite;
$wp_rewrite->add_rule( $regex, $query, $after );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 4.4.0 | Array support was added to the $query parameter. |
| 2.1.0 | Introduced. |

