apply_filters( ‘wp_sitemaps_posts_entry’, array $sitemap_entry, WP_Post $post, string $post_type )

Filters the sitemap entry for an individual post.

Parameters

$sitemap_entryarray
Sitemap entry for the post.
$postWP_Post
Post object.
$post_typestring
Name of the post_type.

Source

$sitemap_entry = apply_filters( 'wp_sitemaps_posts_entry', $sitemap_entry, $post, $post_type );

Changelog

VersionDescription
5.5.0Introduced.

User Contributed Notes

  1. Skip to note 4 content

    To alter the post URLs in WP Multisites,

    add_filter( 'wp_sitemaps_posts_entry', 'wpdocs_sitemaps_posts_entry_callback', 10, 2 );
    
    function wpdocs_sitemaps_posts_entry_callback( $sitemap_entry, $post ) {
    	switch_to_blog( get_blog_id_from_url( $_SERVER['HTTP_HOST'] ) );
    	$sitemap_entry['loc'] = get_permalink( $post );
    
    	return $sitemap_entry; 
    }

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