Filter hook 'post_rewrite_rules'

in WP Core File wp-includes/class-wp-rewrite.php at line 1319

View Source

post_rewrite_rules

Filter Hook
Description
Filters rewrite rules used for "post" archives.

Hook Information

File Location wp-includes/class-wp-rewrite.php View on GitHub
Hook Type Filter
Line Number 1319

Hook Parameters

Type Name Description
string[] $post_rewrite Array of rewrite rules for posts, keyed by their regex pattern.

Usage Examples

Basic Usage
<?php
// Hook into post_rewrite_rules
add_filter('post_rewrite_rules', 'my_custom_filter', 10, 1);

function my_custom_filter($post_rewrite) {
    // Your custom filtering logic here
    return $post_rewrite;
}

Source Code Context

wp-includes/class-wp-rewrite.php:1319 - How this hook is used in WordPress core
<?php
1314  		 *
1315  		 * @since 1.5.0
1316  		 *
1317  		 * @param string[] $post_rewrite Array of rewrite rules for posts, keyed by their regex pattern.
1318  		 */
1319  		$post_rewrite = apply_filters( 'post_rewrite_rules', $post_rewrite );
1320  
1321  		// Date rewrite rules.
1322  		$date_rewrite = $this->generate_rewrite_rules( $this->get_date_permastruct(), EP_DATE );
1323  
1324  		/**

PHP Documentation

<?php
/**
		 * Filters rewrite rules used for "post" archives.
		 *
		 * @since 1.5.0
		 *
		 * @param string[] $post_rewrite Array of rewrite rules for posts, keyed by their regex pattern.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/class-wp-rewrite.php
Related Hooks

Related hooks will be displayed here in future updates.