Filter sitemap URL item before rendering it as XML.
Parameters
- $tree
array Associative array representing sitemap URL element.
- $post_id
int ID of the post being processed.
Changelog
- Introduced in Jetpack 3.9.0
How to use this hook
Notes
You can use that filter to enter a custom value for one or multiple entries in the sitemap generated by Jetpack. In the example below, we’ll change thechangefreq value for all posts, from monthly to daily:
function jeherve_custom_freq_posts_sitemaps( $url, $post_id ) {
$type = get_post_type( $post_id );
if ( 'post' == $type ) {
unset( $url['changefreq'] );
$url['changefreq'] = 'daily';
}
return $url;
}
add_filter( 'jetpack_sitemap_url', 'jeherve_custom_freq_posts_sitemaps', 10, 2 );