W3cubDocs

/WordPress

WP_Sitemaps::init()

Initiates all sitemap functionality.

Description

If sitemaps are disabled, only the rewrite rules will be registered by this method, in order to properly send 404s.

Source

public function init() {
	// These will all fire on the init hook.
	$this->register_rewrites();

	add_action( 'template_redirect', array( $this, 'render_sitemaps' ) );

	if ( ! $this->sitemaps_enabled() ) {
		return;
	}

	$this->register_sitemaps();

	// Add additional action callbacks.
	add_filter( 'robots_txt', array( $this, 'add_robots' ), 0, 2 );
}

Changelog

Version Description
5.5.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_sitemaps/init