WP_Sitemaps::init() WordPress Method

The WP_Sitemaps::init() method is used to initialize the sitemaps feature of WordPress. This method is called during the WordPress initialization process.

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.


Top ↑

Source

File: wp-includes/sitemaps/class-wp-sitemaps.php

	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( 'pre_handle_404', array( $this, 'redirect_sitemapxml' ), 10, 2 );
		add_filter( 'robots_txt', array( $this, 'add_robots' ), 0, 2 );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.