apply_filters( ‘wp_sitemaps_index_entry’, array $sitemap_entry, string $object_type, string $object_subtype, int $page )

Filters the sitemap entry for the sitemap index.

Parameters

$sitemap_entryarray
Sitemap entry for the post.
$object_typestring
Object empty name.
$object_subtypestring
Object subtype name.
Empty string if the object type does not support subtypes.
$pageint
Page number of results.

Source

$sitemap_entry = apply_filters( 'wp_sitemaps_index_entry', $sitemap_entry, $this->object_type, $type['name'], $page );

Changelog

VersionDescription
5.5.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    To alter the home URL for the sitemap index in WP Multisites,

    add_filter( 'wp_sitemaps_index_entry', 'wpdocs_sitemaps_index_entry_callback' );
    function wpdocs_sitemaps_index_entry_callback( $sitemap_entry ) {
    	switch_to_blog( get_blog_id_from_url( $_SERVER['HTTP_HOST'] ) );
    	$link_array = explode( '/', $sitemap_entry['loc'] );
    	$sitemap_url_element = end( $link_array );
    	$sitemap_entry['loc'] = home_url( $sitemap_url_element );
    
    	return $sitemap_entry; 
    }

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