Filters the full set of generated rewrite rules.
Parameters
$rules
string[]- The compiled array of rewrite rules, keyed by their regex pattern.
Source
$this->rules = apply_filters( 'rewrite_rules_array', $this->rules );
Changelog
Version | Description |
---|---|
1.5.0 | Introduced. |
Here is a quick and dirty way you can list all Rewrite Rules registered on your site:
You could also drop this somewhere on your page:
rewrite_rules_array
is only applied whenWP_Rewrite::rewrite_rules()
is called, so yourvar_dump()
call will only dump the rules when they are generated, since that is the only time thatWP_Rewrite::rewrite_rules()
is called. Also, the variableWP_Rewrite::rules
may not be populated when you try to dump it. The proper way to do this is to useWP_Rewrite::wp_rewrite_rules()
, which can be called at any time, and ensures thatWP_Rewrite::rules
is populated. For example, to dump the rewrite rules belonging to the global API:Example migrated from Codex:
Removing Feed URLs
This example demonstrates how you would remove feed URLs for a custom post type called ‘foo’
Example migrated from Codex:
Sample Rewrite Rule Array
This shows one example of what a
var_dump()
of a rewrite array might look like. Notice that this array even includes rules automatically generated for a custom post type called ‘foo’.array (size=103)
'foo/?$' => string 'index.php?post_type=foo' (length=23)
'foo/page/([0-9]{1,})/?$' => string 'index.php?post_type=foo&paged=$matches[1]' (length=41)
'wp-types-group/[^/]+/attachment/([^/]+)/?$' => string 'index.php?attachment=$matches[1]' (length=32)
'wp-types-group/[^/]+/attachment/([^/]+)/trackback/?$' => string 'index.php?attachment=$matches[1]&tb=1' (length=37)
'wp-types-group/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'wp-types-group/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'wp-types-group/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => string 'index.php?attachment=$matches[1]&cpage=$matches[2]' (length=50)
'wp-types-group/([^/]+)/trackback/?$' => string 'index.php?wp-types-group=$matches[1]&tb=1' (length=41)
'wp-types-group/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?wp-types-group=$matches[1]&feed=$matches[2]' (length=53)
'wp-types-group/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?wp-types-group=$matches[1]&feed=$matches[2]' (length=53)
'wp-types-group/([^/]+)/page/?([0-9]{1,})/?$' => string 'index.php?wp-types-group=$matches[1]&paged=$matches[2]' (length=54)
'wp-types-group/([^/]+)/comment-page-([0-9]{1,})/?$' => string 'index.php?wp-types-group=$matches[1]&cpage=$matches[2]' (length=54)
'wp-types-group/([^/]+)(/[0-9]+)?/?$' => string 'index.php?wp-types-group=$matches[1]&page=$matches[2]' (length=53)
'wp-types-group/[^/]+/([^/]+)/?$' => string 'index.php?attachment=$matches[1]' (length=32)
'wp-types-group/[^/]+/([^/]+)/trackback/?$' => string 'index.php?attachment=$matches[1]&tb=1' (length=37)
'wp-types-group/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'wp-types-group/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'wp-types-group/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => string 'index.php?attachment=$matches[1]&cpage=$matches[2]' (length=50)
'foo/[^/]+/attachment/([^/]+)/?$' => string 'index.php?attachment=$matches[1]' (length=32)
'foo/[^/]+/attachment/([^/]+)/trackback/?$' => string 'index.php?attachment=$matches[1]&tb=1' (length=37)
'foo/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'foo/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'foo/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => string 'index.php?attachment=$matches[1]&cpage=$matches[2]' (length=50)
'foo/([^/]+)/trackback/?$' => string 'index.php?foo=$matches[1]&tb=1' (length=30)
'foo/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?foo=$matches[1]&feed=$matches[2]' (length=42)
'foo/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?foo=$matches[1]&feed=$matches[2]' (length=42)
'foo/([^/]+)/page/?([0-9]{1,})/?$' => string 'index.php?foo=$matches[1]&paged=$matches[2]' (length=43)
'foo/([^/]+)/comment-page-([0-9]{1,})/?$' => string 'index.php?foo=$matches[1]&cpage=$matches[2]' (length=43)
'foo/([^/]+)(/[0-9]+)?/?$' => string 'index.php?foo=$matches[1]&page=$matches[2]' (length=42)
'foo/[^/]+/([^/]+)/?$' => string 'index.php?attachment=$matches[1]' (length=32)
'foo/[^/]+/([^/]+)/trackback/?$' => string 'index.php?attachment=$matches[1]&tb=1' (length=37)
'foo/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'foo/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'foo/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => string 'index.php?attachment=$matches[1]&cpage=$matches[2]' (length=50)
'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?category_name=$matches[1]&feed=$matches[2]' (length=52)
'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?category_name=$matches[1]&feed=$matches[2]' (length=52)
'category/(.+?)/page/?([0-9]{1,})/?$' => string 'index.php?category_name=$matches[1]&paged=$matches[2]' (length=53)
'category/(.+?)/?$' => string 'index.php?category_name=$matches[1]' (length=35)
'tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?tag=$matches[1]&feed=$matches[2]' (length=42)
'tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?tag=$matches[1]&feed=$matches[2]' (length=42)
'tag/([^/]+)/page/?([0-9]{1,})/?$' => string 'index.php?tag=$matches[1]&paged=$matches[2]' (length=43)
'tag/([^/]+)/?$' => string 'index.php?tag=$matches[1]' (length=25)
'type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?post_format=$matches[1]&feed=$matches[2]' (length=50)
'type/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?post_format=$matches[1]&feed=$matches[2]' (length=50)
'type/([^/]+)/page/?([0-9]{1,})/?$' => string 'index.php?post_format=$matches[1]&paged=$matches[2]' (length=51)
'type/([^/]+)/?$' => string 'index.php?post_format=$matches[1]' (length=33)
'robots\.txt$' => string 'index.php?robots=1' (length=18)
'.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => string 'index.php?feed=old' (length=18)
'.*wp-app\.php(/.*)?$' => string 'index.php?error=403' (length=19)
'.*wp-register.php$' => string 'index.php?register=true' (length=23)
'feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?&feed=$matches[1]' (length=27)
'(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?&feed=$matches[1]' (length=27)
'page/?([0-9]{1,})/?$' => string 'index.php?&paged=$matches[1]' (length=28)
'comments/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?&feed=$matches[1]&withcomments=1' (length=42)
'comments/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?&feed=$matches[1]&withcomments=1' (length=42)
'comments/page/?([0-9]{1,})/?$' => string 'index.php?&paged=$matches[1]' (length=28)
'search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?s=$matches[1]&feed=$matches[2]' (length=40)
'search/(.+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?s=$matches[1]&feed=$matches[2]' (length=40)
'search/(.+)/page/?([0-9]{1,})/?$' => string 'index.php?s=$matches[1]&paged=$matches[2]' (length=41)
'search/(.+)/?$' => string 'index.php?s=$matches[1]' (length=23)
'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?author_name=$matches[1]&feed=$matches[2]' (length=50)
'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?author_name=$matches[1]&feed=$matches[2]' (length=50)
'author/([^/]+)/page/?([0-9]{1,})/?$' => string 'index.php?author_name=$matches[1]&paged=$matches[2]' (length=51)
'author/([^/]+)/?$' => string 'index.php?author_name=$matches[1]' (length=33)
'([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]' (length=80)
'([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]' (length=80)
'([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => string 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]' (length=81)
'([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => string 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]' (length=63)
'([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]' (length=64)
'([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]' (length=64)
'([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => string 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]' (length=65)
'([0-9]{4})/([0-9]{1,2})/?$' => string 'index.php?year=$matches[1]&monthnum=$matches[2]' (length=47)
'([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?year=$matches[1]&feed=$matches[2]' (length=43)
'([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?year=$matches[1]&feed=$matches[2]' (length=43)
'([0-9]{4})/page/?([0-9]{1,})/?$' => string 'index.php?year=$matches[1]&paged=$matches[2]' (length=44)
'([0-9]{4})/?$' => string 'index.php?year=$matches[1]' (length=26)
'.?.+?/attachment/([^/]+)/?$' => string 'index.php?attachment=$matches[1]' (length=32)
'.?.+?/attachment/([^/]+)/trackback/?$' => string 'index.php?attachment=$matches[1]&tb=1' (length=37)
'.?.+?/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'.?.+?/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'.?.+?/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => string 'index.php?attachment=$matches[1]&cpage=$matches[2]' (length=50)
'(.?.+?)/trackback/?$' => string 'index.php?pagename=$matches[1]&tb=1' (length=35)
'(.?.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?pagename=$matches[1]&feed=$matches[2]' (length=47)
'(.?.+?)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?pagename=$matches[1]&feed=$matches[2]' (length=47)
'(.?.+?)/page/?([0-9]{1,})/?$' => string 'index.php?pagename=$matches[1]&paged=$matches[2]' (length=48)
'(.?.+?)/comment-page-([0-9]{1,})/?$' => string 'index.php?pagename=$matches[1]&cpage=$matches[2]' (length=48)
'(.?.+?)(/[0-9]+)?/?$' => string 'index.php?pagename=$matches[1]&page=$matches[2]' (length=47)
'[^/]+/attachment/([^/]+)/?$' => string 'index.php?attachment=$matches[1]' (length=32)
'[^/]+/attachment/([^/]+)/trackback/?$' => string 'index.php?attachment=$matches[1]&tb=1' (length=37)
'[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => string 'index.php?attachment=$matches[1]&cpage=$matches[2]' (length=50)
'([^/]+)/trackback/?$' => string 'index.php?name=$matches[1]&tb=1' (length=31)
'([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?name=$matches[1]&feed=$matches[2]' (length=43)
'([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?name=$matches[1]&feed=$matches[2]' (length=43)
'([^/]+)/page/?([0-9]{1,})/?$' => string 'index.php?name=$matches[1]&paged=$matches[2]' (length=44)
'([^/]+)/comment-page-([0-9]{1,})/?$' => string 'index.php?name=$matches[1]&cpage=$matches[2]' (length=44)
'([^/]+)(/[0-9]+)?/?$' => string 'index.php?name=$matches[1]&page=$matches[2]' (length=43)
'[^/]+/([^/]+)/?$' => string 'index.php?attachment=$matches[1]' (length=32)
'[^/]+/([^/]+)/trackback/?$' => string 'index.php?attachment=$matches[1]&tb=1' (length=37)
'[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => string 'index.php?attachment=$matches[1]&feed=$matches[2]' (length=49)
'[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => string 'index.php?attachment=$matches[1]&cpage=$matches[2]' (length=50)