WordPress开发者和主题制作者的搜索引擎



add_rewrite_rule ›

Since2.1.0
已弃用n/a
add_rewrite_rule ( $regex, $query, $after = 'bottom' )
参数: (3)
  • (string) $regex Regular expression to match request against.
    Required: Yes
  • (string|array) $query The corresponding query vars for this rewrite rule.
    Required: Yes
  • (string) $after Optional. Priority of the new rule. Accepts 'top' or 'bottom'. Default 'bottom'.
    Required: No
    默认: 'bottom'
定义在:
文档:
Change Log:
  • 4.4.0

Adds a rewrite rule that transforms a URL structure to a set of query vars.

Any value in the $after parameter that isn't 'bottom' will result in the rule being placed at the top of the rewrite rules.



源码

function add_rewrite_rule( $regex, $query, $after = 'bottom' ) {
	global $wp_rewrite;

	$wp_rewrite->add_rule( $regex, $query, $after );
}