Skip to content

Instantly share code, notes, and snippets.

@remkus
Created August 7, 2015 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remkus/ea2545316544f4c88b18 to your computer and use it in GitHub Desktop.
Save remkus/ea2545316544f4c88b18 to your computer and use it in GitHub Desktop.
<?php
add_filter('wpseo_sitemap_index', 'add_subdomains_to_sitemap' ); // add link to custom sitemap
/**
* Add the link to the main sitemap index
* @param string $content Existing sitemap content.
* @return string Sitemap with extra content.
*/
function add_subdomains_to_sitemap( $content = '' ) {
$sites = array(
'http://1.example.com/sitemap_index.xml',
'http://2.example.com/sitemap_index.xml',
'http://3.example.com/sitemap_index.xml',
);
foreach($sites as $site) {
$content .= '<sitemap>' . "\n";
$content .= ' <loc>' . $site . '</loc>' . "\n";
$content .= ' <lastmod>'.date('c').'</lastmod>' . "\n";
$content .= '</sitemap>' . "\n";
}
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment