WP_Rewrite::add_rule

SummerySummery

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

Syntax

WP_Rewrite::add_rule( string $regex, string|array $query, string $after = 'bottom' )

DescriptionDescription

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

ParametersParameters

$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 value: 'bottom'

SourceSource

File: wp-includes/class-wp-rewrite.php


			

ChangelogChangelog

Changelog
Version Description
4.4.0 Array support was added to the $query parameter.
2.1.0 Introduced.
Scroll to Top