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

Filters the sitemap entry for an individual post.


$sitemap_entry array
Sitemap entry for the post.
$post WP_Post
Post object.
$post_type string
Name of the post_type.

Top ↑


File: wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php. View all references

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

Top ↑


Version Description
5.5.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 2 content
    Contributed by Harit Panchal

    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.