WP_Sitemaps::redirect_sitemapxml( bool $bypass, WP_Query $query ): bool

In this article

This method has been deprecated. Deprecated in favor of {@see WP_Rewrite::rewrite_rules()} instead.

Redirects a URL to the wp-sitemap.xml

Parameters

$bypassboolrequired
Pass-through of the pre_handle_404 filter value.
$queryWP_Queryrequired
The WP_Query object.

Return

bool Bypass value.

Source

public function redirect_sitemapxml( $bypass, $query ) {
	_deprecated_function( __FUNCTION__, '6.7.0' );

	// If a plugin has already utilized the pre_handle_404 function, return without action to avoid conflicts.
	if ( $bypass ) {
		return $bypass;
	}

	// 'pagename' is for most permalink types, name is for when the %postname% is used as a top-level field.
	if ( 'sitemap-xml' === $query->get( 'pagename' )
		|| 'sitemap-xml' === $query->get( 'name' )
	) {
		wp_safe_redirect( $this->index->get_index_url() );
		exit();
	}

	return $bypass;
}

Changelog

VersionDescription
6.7.0Deprecated in favor of WP_Rewrite::rewrite_rules()
5.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.