Created
August 7, 2015 18:18
-
-
Save remkus/ea2545316544f4c88b18 to your computer and use it in GitHub Desktop.
This file contains 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 | |
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