Programmatically rebuild links

Created on 30 January 2020, about 5 years ago
Updated 14 March 2025, about 1 month ago

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!

💬 Support request
Status

Active

Version

2.6

Component

Code

Created by

🇮🇹Italy smurfxx

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States j_s

    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);
    
Production build 0.71.5 2024