1

I have several existing custom sitemap xml files, and I'd like to know which add_filter to use to add those custom sitemaps to the existing https://www.example.com/wp-sitemap.xml page.

0

There are a lot to choose from.

I would start with wp_sitemap_init, whose documentation states

Additional sitemaps should be registered on this hook.

Note that you'll have to be running WordPress 5.5.0 or up for this hook to be available.

Looking at the code, it appears that this action allows you to register new items in the global $wp_sitemaps object, which is a WP_Sitemaps object.

2
  • Thank you. I have definitely seen the links you provided, and have seen several examples of registering a new sitemap provider, etc. but they all seem overkill if all I'm wanting to do is add a couple of sitemap xml file links inside the existing default wp-sitemaps.xml file. Any insight on a simpler approach is much appreciated.
    – l_r
    Jan 12 at 19:40
  • I did a bunch of work on a Multisite sitemap for my employer's website, but it appears I ignored all the filters (or—since it was a while ago—some of the filters might not have existed yet) and basically wrote something up from essentially scratch.
    – Pat J
    Jan 13 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.