Filter hook 'wp_sitemaps_enabled'

in WP Core File wp-includes/sitemaps/class-wp-sitemaps.php at line 104

View Source

wp_sitemaps_enabled

Filter Hook
Description
Filters whether XML Sitemaps are enabled or not. When XML Sitemaps are disabled via this filter, rewrite rules are still in place to ensure a 404 is returned.

Hook Information

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

Hook Parameters

Type Name Description
bool $is_enabled Whether XML Sitemaps are enabled or not. Defaults to true for public sites.

Usage Examples

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

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

Source Code Context

wp-includes/sitemaps/class-wp-sitemaps.php:104 - How this hook is used in WordPress core
<?php
  99  		 * @since 5.5.0
 100  		 *
 101  		 * @param bool $is_enabled Whether XML Sitemaps are enabled or not.
 102  		 *                         Defaults to true for public sites.
 103  		 */
 104  		return (bool) apply_filters( 'wp_sitemaps_enabled', $is_enabled );
 105  	}
 106  
 107  	/**
 108  	 * Registers and sets up the functionality for all supported sitemaps.
 109  	 *

PHP Documentation

<?php
/**
		 * Filters whether XML Sitemaps are enabled or not.
		 *
		 * When XML Sitemaps are disabled via this filter, rewrite rules are still
		 * in place to ensure a 404 is returned.
		 *
		 * @see WP_Sitemaps::register_rewrites()
		 *
		 * @since 5.5.0
		 *
		 * @param bool $is_enabled Whether XML Sitemaps are enabled or not.
		 *                         Defaults to true for public sites.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/sitemaps/class-wp-sitemaps.php
Related Hooks

Related hooks will be displayed here in future updates.