aioseo_sitemap_post

This filter can be used to advertise the translated versions of a post so that these can be included in the multilingual sitemap of AIOSEO.

Parameters (3)

$entry (array)
The sitemap entry data.

$postId (int)
The post ID.

$postType (string)
The post type.

Example code snippet

The code snippet below can be used to add translated versions for a specific post sitemap entry.

add_filter( "aioseo_sitemap_post", "aioseo_filter_sitemap_post", 10, 2 );

function aioseo_filter_sitemap_post( $entry, $postId ) {
	if ( 10 === $postId ) {
		// Set the language code for the main URL.
        $entry['language']  = 'en_US'

		// Add the translated versions (language code + URL).
		$entry['languages'] = [
			[
				'language' => 'en_CA'
				'location' => 'https://example.com/ca/page
			],
			[
				'language' => 'en_UK'
				'location' => 'https://example.com/uk/page
			]
		];
	}
	return $entry;
}

Changelog

VersionDescription
4.2.2Introduced.