WP_Rewrite::add_rewrite_tag

SummerySummery

Adds or updates existing rewrite tags (e.g. %postname%).

Syntax

WP_Rewrite::add_rewrite_tag( string $tag, string $regex, string $query )

DescriptionDescription

If the tag already exists, replace the existing pattern and query for that tag, otherwise add the new tag.

ParametersParameters

$tag

(string) (Required) Name of the rewrite tag to add or update.

$regex

(string) (Required) Regular expression to substitute the tag for in rewrite rules.

$query

(string) (Required) String to append to the rewritten query. Must end in '='.

SourceSource

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


			

ChangelogChangelog

Changelog
Version Description
1.5.0 Introduced.

See alsoSee also

  • WP_Rewrite::$rewritecode
  • WP_Rewrite::$rewritereplace
  • WP_Rewrite::$queryreplace
Scroll to Top