Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save markbosky/d98b299d010fe2dacc96c8a675d2a4cf to your computer and use it in GitHub Desktop.
Save markbosky/d98b299d010fe2dacc96c8a675d2a4cf to your computer and use it in GitHub Desktop.
Remove post-sitemap.xml link from sitemap_index.xml in Yoast SEO WordPress
<?php
//Remove post-sitemap.xml from Yoast Sitemap index without affecting indexability
add_filter('wpseo_sitemap_index_links', function ($sitemaps) {
foreach ($sitemaps as $key => $sitemap) {
if (isset($sitemap['loc']) && strpos($sitemap['loc'], 'post-sitemap.xml') !== false) {
unset($sitemaps[$key]);
}
}
return $sitemaps;
});
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment