My WordPress site also incorporates some external non-WP content that is dynamically pulled into the page via shortcode. The content shown depends on a query string parameter. So from WP’s point of view, index
is just a single page containing a shortcode; but in reality, when you visit index?x=1
, index?x=2
, index?x=3
, etc. you get different page content depending on the x
value. (It’s a primary key ID into a large external database.)
This works fine, and avoids creating thousands of separate pages in WP, though I do have to filter get_canonical_url
to ensure that the canonical URL retains the query string with the x
value (which would otherwise be stripped out by WP).
Now I want to include all of these pages in WP’s auto-generated sitemap (/wp-sitemap.xml
), which, again, currently only lists the single bare URL with no x
value. I need the sitemap to include index?x=1
, index?x=2
, index?x=3
, etc. to cover every extant ID value.
I can easily write PHP code to generate a list of these URLs, but how do I hook into the sitemap generation process to add them to the default list produced by WP?