• Resolved ctmartin2020

    (@ctmartin2020)


    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);
    }

    However, now with the latest version, I get a PHP fatal error. It appears the AddElement function does not work now:

    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)
  • Plugin Author Auctollo

    (@auctollo)

    @ctmartin2020, thanks for using the plugin. We had to rename the function due to PHPCS standards to “add_element”. Please use the same in functions.php and let us know if there are any issues!

Viewing 1 replies (of 1 total)
  • The topic ‘PHP Fatal Error’ is closed to new replies.