rewrite_rules_array WordPress Filter Hook

The rewrite_rules_array hook is used to modify the array of rewrite rules used by WordPress. This can be used to add or remove rules, or to modify existing rules.

apply_filters( 'rewrite_rules_array', string[] $rules ) #

Filters the full set of generated rewrite rules.


Parameters

$rules

(string[])The compiled array of rewrite rules, keyed by their regex pattern.


Top ↑

More Information

  • This filter hook can be used to any rule in the rewrite rules array.
  • Since rewrite rules are saved to the database, you must flush/update your rules from your admin under Settings > Permalinks before your changes will take effect. You can also use the flush_rules() function to do this programmatically.
  • Make sure you return the $rules array or very bad things will happen.

Top ↑

Source

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

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
1.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.