Action and Filter hooks

A quick overview of all available action and filter hooks in XML Sitemap & Google News.

Action hooks

Hook nameContextDescription
xmlsf_generatorXML Sitemap, Google NewsFired before each sitemap’s <urlset> tag.
xmlsf_pingRemoved since 5.4Fires when a search engine has been pinged. Carries four arguments: search engine (google|yandex|bing), sitemap name, full ping URL, ping response code.
xmlsf_sitemap_indexXML Sitemap IndexFired before any sitemap are added to the index.
xmlsf_sitemap_index_afterXML Sitemap IndexFired after all sitemaps are added to the index.
xmlsf_urlsetXML SitemapFired inside each sitemap’s <urlset> tag. Can be used to echo additional XML namespaces. Passes the sitemap type home|post_type|taxonomy|custom to allow identification of the current sitemap.
xmlsf_urlXML SitemapFired inside the XML Sitemap loop at the start of each sitemap <url> tag. Passes the sitemap type home|post_type|taxonomy|custom and entry object/data.
xmlsf_image_tags_innerXML SitemapFired inside the XML Sitemap loop just before each closing </image:image> is generated. Can be used to echo custom <image:image> tags or trigger another action in the background.
xmlsf_tags_afterXML SitemapFired inside the XML Sitemap loop at the end of the tags, just before each closing </url> is generated. Passes the sitemap type home|post_type|taxonomy|custom and entry object/data. Can be used to echo custom tags or trigger another action in the background.
xmlsf_url_afterXML SitemapFired inside the XML Sitemap loop after each <url> node. Passes the sitemap type home|post_type|taxonomy|custom and entry object/data. Can be used to append alternative URL or trigger another action in the background.
xmlsf_news_urlsetGoogle NewsFired inside the Google News Sitemap urlset tag. Can be used to echo additional XML namespaces.
xmlsf_news_tags_innerGoogle NewsFired inside the Google News Sitemap loop at the end of the news tags, just before each closing </news:news> is generated. Passes the post object to allow identification of the current entry. Can be used to echo custom news:news tags or trigger another action in the background.
xmlsf_news_tags_afterGoogle NewsFired inside the Google News Sitemap loop at the end of the news tags, just before each closing </url> is generated. Passes the post object to allow identification of the current entry. Can be used to echo custom news tags or trigger another action in the background.
xmlsf_news_url_afterGoogle NewsFired inside the Google News Sitemap loop after each news URL node. Passes the post object to allow identification of the current entry. Can be used to append alternative URL or trigger another action in the background.
xmlsf_news_settings_beforeAdminFired before the Google News Sitemap settings form.
xmlsf_news_settings_afterAdminFired after the Google News Sitemap settings form.

Filter hooks

Hook nameContextDescription
xmlsf_sitemaps_enabledAdmin, XML Sitemap, Google NewsFilters the sitemap states. Passes parameters enabled state true|false and which sitemap any|sitemap|news. You can use __return_false to turn off all sitemaps.
xmlsf_defaultsAdmin, XML Sitemap, Google NewsFilters the default array values for different option groups.
xmlsf_requestXML SitemapFilters request when an XML sitemap request is found, can be used for plugin compatibility.
xmlsf_news_requestGoogle NewsFilters request when a news sitemap request is found can be used for plugin compatibility.
xmlsf_stylesheet_urlXML Sitemap, Google NewsFilters the sitemaps style sheet URL.
xmlsf_allowed_domainRemoved since 5.4Filters the response when checking the URL against allowed domains. Passes variable $url; must return true or false. Use filter xmlsf_entry_url instead.
xmlsf_index_url_argsXML Sitemap IndexFilters the index URL arguments array.
xmlsf_index_archive_dataXML Sitemap IndexFilters the post type sitemaps in the index.
xmlsf_entry_urlXML SitemapFilters the entry URL in XML Sitemap context. Passes the entry $url, sitemap type home|post_type|taxonomy|author|custom and entry object/data; must return a URL or false. Returning false will exclude the entry from the sitemap.
xmlsf_news_entry_urlGoogle NewsFilters the entry URL in Google News Sitemap context. Passes the entry $url and entry object; must return a URL or false. Returning false will exclude the entry from the news sitemap.
xmlsf_excludedXML SitemapFilters the response when checking the post for exclusion flags in XML Sitemap context. Passes the post exclusion flag and $post_id; must return true or false.
xmlsf_news_excludedGoogle NewsFilters the response when checking the post for exclusion flags in Google News sitemap context. Passes variable $post_id; must return true or false.
xmlsf_news_keywordsGoogle NewsFilters the news keywords array.
xmlsf_news_stock_tickersGoogle NewsFilters the news stock tickers array.
xmlsf_disabled_post_typesXML Sitemap, Google NewsFilters the post types that should be unavailable for sitemaps. Passes an array of post types to exclude; must return an array.
xmlsf_disabled_taxonomiesXML SitemapFilters the taxonomies that should be unavailable for sitemaps. Passes an array of taxonomies to exclude; must return an array.
the_title_xmlsitemapRemoved since 5.4Filters the Image title and caption tags.
xmlsf_news_publication_nameGoogle NewsFilters the Google News publication name.
xmlsf_news_titleGoogle NewsFilters the Google News post title.
xmlsf_root_dataXML SitemapFilters the root data URLs (with priority and lastmod) array.
xmlsf_custom_urlsXML SitemapFilters the custom URLs array.
xmlsf_custom_sitemapsXML Sitemap IndexFilters the custom sitemaps array.
xmlsf_news_languageGoogle NewsFilters the post language tag used in the news sitemap. Passes variable $post_id; must return a 2 or 3 letter ISO 639 language code with the exception of zh-cn and zh-tw.
xmlsf_post_typesXML Sitemap IndexFilters the post types array for the XML sitemaps index.
xmlsf_post_priorityXML SitemapFilters a post priority value. Passes variables $priority and $post->ID. Must return a float value between 0.1 and 1.0
xmlsf_term_priorityXML SitemapFilters a taxonomy term priority value. Passes variables $priority and $term->slug. Must return a float value between 0.1 and 1.0
xmlsf_author_has_published_postsXML SitemapFilters the has_published_posts query argument in the author archive. Passes variable array('post'). Must return a boolean or an array of one or more (public) post type slugs.
xmlsf_news_post_typesAdmin, Google NewsFilters the post types array for both the Google News sitemap and the Google News settings page.
xmlsf_stylesheet_urlXML Sitemap, Google NewsFilters the sitemaps style sheet URL.
xmlsf_get_author_argsXML SitemapFilters the get_users() arguments before author sitemap creation.
xmlsf_skip_userXML SitemapAllows excluding users from the author sitemap. Passes the $user object with ID, login, spam, deleted properties, unless set otherwise via the fields argument through the xmlsf_get_author_args filter. Expects a boolean value (true|false) in return. False by default. Since v5.3.
xmlsf_news_help_tabsAdminFired after the Google News admin help tabs have been added.