My site has some specific access/pubblication workflows about nodes so I'd like to run via code the rebuild function of your module that I find in admin/config/search/xmlsitemap/rebuild

I tried with this custom code during a cron job:

module_load_include('admin.inc', 'xmlsitemap');
xmlsitemap_rebuild_form();

This doesn't returns me errors but I see the form does not add new links to my sitemap.xml file but if I run it manually from the page it works.

Can you please tell me ho to trigger via code the rebuild of XML sitemap?

Thanks!

Comments

smurfxx created an issue.

daniel_arend’s picture

In my case, this works:


  module_load_include('generate.inc', 'xmlsitemap');
  // Run the batch process.
  xmlsitemap_run_unprogressive_batch('xmlsitemap_regenerate_batch');
j_s’s picture

Old but still active issue. For 8.x-1.5, this worked for me:

$rebuild_types = xmlsitemap_get_rebuildable_link_types();
$batch = xmlsitemap_rebuild_batch($rebuild_types, TRUE);
batch_set($batch);