Created
March 12, 2025 22:36
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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