Filters the entry URL in XML Sitemap context when the sitemaps Server is set to Plugin.
apply_filters( 'xmlsf_entry_url', string[] $url , string[] $sitemap, obj[] $object )
Used in xml-sitemap-feed/views/feed-sitemap-taxonomy.php
Parameters (3)
- $url
(string)
The original entry URL. - $sitemap
(string) The sitemap type, one of:post_type|taxonomy|author
- $object
(obj)
The current entry object, one of:WP_Post|WP_Term|WP_User
Return
(string|bool)
Entry URL or false
Must return a URL or false. Returning false will exclude the entry from the sitemap.
Usage example
function my_tax_term_entry_exclusion( $url, $sitemap, $object ) {
// Skip if not in taxonomy sitemap context.
if ( 'taxonomy' !== $sitemap ) {
return $url;
}
// In a taxonomy sitemap context, our $object is a WP_Term object.
// Exclude term by ID.
$term_ids = array( 9, 123, 556 ) ;
if ( in_array( $object->term_id, $term_ids ) ) {
return false;
}
// Return original URL.
return $url;
}
add_filter( 'xmlsf_entry_url', 'my_tax_term_entry_exclusion', 10, 3 );
Related
Used by | Description |
---|---|
none |