Filter hook 'comments_rewrite_rules'

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

View Source

comments_rewrite_rules

Filter Hook
Description
Filters rewrite rules used for comment feed archives. Likely comments feed archives include `/comments/feed/` and `/comments/feed/atom/`.

Hook Information

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

Hook Parameters

Type Name Description
string[] $comments_rewrite Array of rewrite rules for the site-wide comments feeds, keyed by their regex pattern.

Usage Examples

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

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

Source Code Context

wp-includes/class-wp-rewrite.php:1362 - How this hook is used in WordPress core
<?php
1357  		 *
1358  		 * @since 1.5.0
1359  		 *
1360  		 * @param string[] $comments_rewrite Array of rewrite rules for the site-wide comments feeds, keyed by their regex pattern.
1361  		 */
1362  		$comments_rewrite = apply_filters( 'comments_rewrite_rules', $comments_rewrite );
1363  
1364  		// Search rewrite rules.
1365  		$search_structure = $this->get_search_permastruct();
1366  		$search_rewrite   = $this->generate_rewrite_rules( $search_structure, EP_SEARCH );
1367  

PHP Documentation

<?php
/**
		 * Filters rewrite rules used for comment feed archives.
		 *
		 * Likely comments feed archives include `/comments/feed/` and `/comments/feed/atom/`.
		 *
		 * @since 1.5.0
		 *
		 * @param string[] $comments_rewrite Array of rewrite rules for the site-wide comments feeds, 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.