apply_filters ( 'jetpack_sitemap_url', array $tree, int $post_id )

Filter sitemap URL item before rendering it as XML.

Source file: modules/sitemaps/sitemap-builder.php

View in GitHub

Parameters

$tree

(array) Associative array representing sitemap URL element.

$post_id

(int) ID of the post being processed.


Changelog

Since: Jetpack 3.9.0


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 the changefreq 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 );

Have a note to contribute?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s