• Resolved worthyofblame

    (@worthyofblame)


    Hi,

    I used to be able to add custom pages to the sitemap using the following function:

    function add_pages_to_sitemap() {
    	$generatorObject = &GoogleSitemapGenerator::GetInstance();
        if($generatorObject!=null) {
        $generatorObject->AddUrl("https://www.example.com/url-1/",mktime(0, 0, 0, 1, 17, 2019),"monthly",0.4);
        $generatorObject->AddUrl("https://www.example.com/url-1/",mktime(0, 0, 0, 1, 17, 2019),"monthly",0.4);
        }
    }
    add_action("sm_buildmap", "add_pages_to_sitemap");

    But now I get the following error:

    PHP Fatal error: Uncaught Error: Call to undefined method GoogleSitemapGenerator::GetInstance()

    Could you please assist in fixing this issue? I can no longer find documentation on how to add pages to the sitemap via PHP (these pages lie outside the WordPress installation).

    Thank you for your help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter worthyofblame

    (@worthyofblame)

    Note I have tested various versions of the plugins and have found:
    4.1.5 is not working
    4.1.4 is not working
    4.1.3 is not working
    4.1.2 is not working
    4.1.1 is working
    4.1.0 is working

    “Not working” = same error as above.

    “Working” = no error.

    Thread Starter worthyofblame

    (@worthyofblame)

    Hi,

    Any response from the plugin authors?

    Thanks for raising the issue. From version 4.1.3 we have changed the methods from camel case to snake case as per the WordPress phpcs standard. So, The method ‘GetInstance’ is now ‘get_instance’ and ‘AddUrl’ is now ‘add_url’. Let us know if you need further assistance on this.

    mkl1

    (@mkl1)

    Good that I found this page.

    Would you mind updating the section Developer Documentation in
    documentation.txt?
    It still shows to the old syntax.

    Thanks
    M

    • This reply was modified 2 years ago by mkl1.
    saurabhdhariwal01

    (@saurabhdhariwal01)

    Hello @mkl1, Thanks for raising the concern. Yes, We have added it to documentation.txt in our upcoming version 4.1.6 which is scheduled to be released soon after we are done with our internal testing and fixes. Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP Fatal Error When Adding Pages To Sitemap’ is closed to new replies.