<permastructname>_rewrite_rules

Filters rewrite rules used for individual permastructs.

Description

apply_filters( '<permastructname>_rewrite_rules', (array) $rules ); 

The dynamic portion(s) of the hook name refer to the name of the registered permastruct, e.g. post_tag (tags), 'category' (categories), etc.

Parameters (1)

0. $rules (array)
The rewrite rules generated for the current permastruct.

Usage

To run the hook, copy the example below.
  1. $rules = apply_filters( '{$permastructname}_rewrite_rules', $rules ); 
  2.  
  3. if ( !empty( $rules ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the <permastructname>_rewrite_rules callback 
  2. function filter_permastructname_rewrite_rules( $rules ) { 
  3. // make filter magic happen here... 
  4. return $rules
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "{$permastructname}_rewrite_rules", 'filter_permastructname_rewrite_rules', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "{$permastructname}_rewrite_rules", 'filter_permastructname_rewrite_rules', 10, 1 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/class-wp-rewrite.php  
  1. $rules = apply_filters( "{$permastructname}_rewrite_rules", $rules );