wp_sitemaps_taxonomies
Allows you to specify which taxonomies should be included in the sitemap.

Usage
add_filter( 'wp_sitemaps_taxonomies', 'wp_kama_sitemaps_taxonomies_filter' );
/**
* Function for `wp_sitemaps_taxonomies` filter-hook.
*
* @param WP_Taxonomy[] $taxonomies Array of registered taxonomy objects keyed by their name.
*
* @return WP_Taxonomy[]
*/
function wp_kama_sitemaps_taxonomies_filter( $taxonomies ){
// filter...
return $taxonomies;
}
- $taxonomies(WP_Taxonomy[])
An array of all public, viewable taxonomy objects, keyed by their names.
Array ( [category] => WP_Taxonomy Object ( [name] => category [label] => Categories ... ) [post_tag] => WP_Taxonomy Object ( [name] => post_tag [label] => Tags ... ) [post_format] => WP_Taxonomy Object ( [name] => post_format [label] => Formats ... ) )
Examples
#1 Exclude a taxonomy from the sitemap
# Remove tags (the post_tag taxonomy) from the sitemap
add_filter( 'wp_sitemaps_taxonomies', function( $taxonomies ) {
unset( $taxonomies['post_tag'] );
return $taxonomies;
} );Changelog
| Since 5.5.0 | Introduced. |
Where the hook is called
wp_sitemaps_taxonomies
wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php 47
return apply_filters( 'wp_sitemaps_taxonomies', $taxonomies );