Simple Sitemaps reverting to non mapped domains...

When we build a new site and map the domain, we are sure to edit one of the pre-installed posts each of our clients gets so that the sitemap will rewrite to the new mapped domain so it reads as instead of

We're noticing that when our users post new content the sitemaps are updating with the new content but rewriting the domain as being unmapped. We thought we saw this a few times but figured we just overlooked something but now clients that had placed tickets regarding the issue where we had fixed the issue for by editing an existing blog post are submitting tickets again as the issue has resurfaced.... it seems as though when they add new posts it reverts to the unmapped version....

Any ideas?

  • Marty Thornley

    Having this same issue. But looking through, seems it might be that the blog issued a sitemap before going to a mapped domain, so the sitemap has just not been updated yet.

    So I had a thought about fixing this so there is no need for publishing a post to force a new sitemap.

    What if you set an option as a sitemap was created, simply storing the current blog's URL, which could be

    Then just add a simple action that check's the current URL against that saved option, if there is a difference, then trigger a new sitemap, using the new URL, which would be Then save that as the option.

    That should trigger a new sitemap as soon as domain mapping goes into effect or as soon as it gets taken off.

    If the URL's match, then nothing happens.

  • Marty Thornley

    In fact... that sounded so easy I did it and it worked!

    Here are the changes...

    in simple-sitemaps.php, added update_option('simple_sitemap_domain',get_bloginfo('url')); after the switch to blog...

    function GenerateSitemap( $blogid ) {
    global $wpdb;

    switch_to_blog( $wpdb->blogid );


    $latestpages = get_posts( 'numberposts=' . $this->totalposts . '&post_type=page' );

    in sitemap.php, added the following, above the check for the cached file...

    So the
    if ( file_exists( $cachefile ) ) {


    $current_domain = get_bloginfo('url');
    $saved_domain = get_option('simple_sitemap_domain');

    if ( $current_domain != $saved_domain ) {

    if ( !class_exists('Incsub_SimpleSitemaps') )
    exit('Plugin missing.');

    $content = $Incsub_SimpleSitemaps->GenerateSitemap( $wpdb->blogid );

    header( 'Content-type: text/xml; charset=utf-8' );
    echo $content;

    echo "\n<!-- Sitemap was generated with the new domain -->";

    } elseif ( file_exists( $cachefile ) ) {


    The first time the blog loads, get_option('simple_sitemap_domain') will be empty and therefore not match the current domain, so I saw the message that a new map was created, the mapped domain was there in all the links.

    The second time, it loaded with the cached message.

    No more un-mapped domains! :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.