-
Hello, as the title suggests, I’m finding that adding custom URLs to the sitemap does not respect the “Links Per Sitemap” setting.
I followed the guidance from here in order to create a filter that adds additional URLs to the sitemap from a custom database table.
It works just fine after regenerating the sitemap, however, the primary issue is that all of the URLs are added to the sitemap without any pagination. So I have well over 200 items on a single sitemap. Is there a way to add these items while ensuring that the sitemap is broken up into separate pages so I can follow best practices? Thank you!
Note: Here is an example of my filter.
function rank_math_add_custom_urls(): string { $urls = ''; $site_url = get_site_url(); foreach(CustomMysql_Util::get_custom_sitemap_links() as $result) { $url = "$site_url" . "$result->uri"; $lastmod = "$result->lastmod"; $value = "<url> <loc>$url</loc> <lastmod>$lastmod</lastmod> </url>"; $urls .= $value; } return $urls; } add_action( 'rank_math/sitemap/page_content', 'rank_math_add_custom_urls', 10 );
The ticket ‘Adding custom URLs to the sitemap does not respect “Links Per Sitemap”’ is closed to new replies.