add_rewrite_rule() WP 1.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.
Works based on: WP_Rewrite::add_rule()
1 time = 0.000001s = speed of light | 50000 times = 0.03s = speed of light | PHP 7.1.11, WP 4.9.8
No Hooks.
Return
Null. Nothing.
Usage
add_rewrite_rule( $regex, $query, $after );
- $regex(string) (required)
- Regular expression to match request against.
- $query(string/array) (required)
- The corresponding query vars for this rewrite rule.
- $after(string)
- Priority of the new rule. Accepts 'top' or 'bottom'.
Default: 'bottom'
Notes
- Global. WP_Rewrite. $wp_rewrite WordPress rewrite component.
Changelog
Since 2.1.0 | Introduced. |
Since 4.4.0 | Array support was added to the $query parameter. |
Code of add_rewrite_rule() add rewrite rule WP 5.6
function add_rewrite_rule( $regex, $query, $after = 'bottom' ) {
global $wp_rewrite;
$wp_rewrite->add_rule( $regex, $query, $after );
}