Modify the sitemap

This snippet for Sitemaps shows how to modify the sitemap depending on your content.

/**
	@brief		Modify the sitemap by controlling the URL objects.
	@since		2018-03-09 12:17:56
**/
function my_broadcast_sitemaps_build_sitemap( $action )
{
	foreach( $action->sitemap->get_urls() as $url )
	{
		$post = $url->post();

		// Pages get a priority of 0.75
		if ( $post->post_type == 'page' )
			$url->set_priority( 0.75 );

		// If the guid contains a specific string, modify the changefreq.
		if ( strpos( $url->get( 'loc' ), '/status/' ) !== false )
			$url->set_changefreq( 'hourly' );

		// Never display the "lastmod" tag.
		$url->collection( 'tags' )->forget( 'lastmod' );
	}
}
add_action( 'broadcast_sitemaps_build_sitemap', 'my_broadcast_sitemaps_build_sitemap' );