• Resolved ipreto

    (@ipreto)


    Hello there.
    I would like to add a page to the sitemap. The problem is the page is not on wordpress but in react. Anyone knows how to manually do it? Thanks

Viewing 1 replies (of 1 total)
  • I used to be able to append to the sitemap using the following function, but it is now not working and serving a fatal error with the latest update. I don’t know what is going on with this plugin, but it doesn’t seem good in this regard. Anyway, here’s what I was able to do prior to the latest revision:

    First, create a separate XML sitemap of your own with the pages you want included. Let’s call it “newpages.xml” and place it in the theme directory where your functions.php lives. Then add this to functions.php:

    /* add custom sitemap to xml sitemap. */
    add_action('sm_build_index', 'addCustomSitemap', 100, 1);
    function addCustomSitemap($gsg) {
       $sitemap = __DIR__.'/newpages.xml
       $sm = new GoogleSitemapGeneratorSitemapEntry($sitemap);
       $gsg->AddElement($sm);
    }

    That’s it.

    However, now with the latest version, I get a PHP fatal error:

    PHP Fatal error:  Uncaught Error: Call to undefined method GoogleSitemapGenerator::AddElement() in /site-home/wp-content/themes/mytheme/functions.php:84
    Stack trace:
    #0 /site-home/wp-includes/class-wp-hook.php(307): addCustomSitemap(Object(GoogleSitemapGenerator))
    #1 /site-home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
    #2 /site-home/wp-includes/plugin.php(474): WP_Hook->do_action(Array)
    #3 /site-home/wp-content/plugins/google-sitemap-generator/sitemap-core.php(1945): do_action('sm_build_index', Object(GoogleSitemapGenerator))
    #4 /site-home/wp-content/plugins/google-sitemap-generator/class-googlesitemapgeneratorloader.php(387): GoogleSitemapGenerator->show_sitemap(Array)
    #5 /site-home/wp-content/plugins/google-sitemap-generator/class-googlesitemapgeneratorloader.php(250): GoogleSitemapGeneratorLoader::call_show_sitemap('params=;html=tr...')
    #6 /site-home/wp-includes/class-wp-hook.php( in /site-home/wp-content/themes/mytheme/functions.php on line 84
Viewing 1 replies (of 1 total)
  • The topic ‘Add a page to sitemap not on wordpress’ is closed to new replies.