Title: Update sitemap programmatically
Last modified: April 7, 2022

---

# Update sitemap programmatically

 *  Resolved [robertrosanke](https://wordpress.org/support/users/robertrosanke/)
 * (@robertrosanke)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/update-sitemap-programmatically/)
 * Hello.
 * As described in this [post about the sitemap](https://wordpress.org/support/topic/add-additional-page-s-to-the-sitemap/)
   I added additional URLs to the sitemap using `add_filter('the_seo_framework_sitemap_additional_urls',...);`.
 * That worked so far.
 * Now, according to the [TSF documentation about the sitemap](https://kb.theseoframework.com/kb/all-you-must-know-about-sitemaps/),
   the sitemap is not dynamically generated, but cached.
 * The following actions should trigger an update:
    - Update or publish any type of post or page
    - Update the permalink settings
    - Or update the SEO settings
 * The contents of the added links are managed via a plugin settings page.
    That
   explains why the sitemap isn’t updating.
 * I called `flush_rewrite_rules()` after updating the plugin settings and content.
   
   However, it doesn’t seem to work. The sitemap does not show the new links.
 * It works when I manually update any page from the admin interface.
 * How can I programmatically update the sitemap after updating the plugin settings?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [robertrosanke](https://wordpress.org/support/users/robertrosanke/)
 * (@robertrosanke)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/update-sitemap-programmatically/#post-15535958)
 * Edit: When I talk about “after updating the plugin settings”, I’m not talking
   about TSF.
    It’s a separate plugin that has nothing to do with TSF.
 *  Plugin Author [Sybre Waaijer](https://wordpress.org/support/users/cybr/)
 * (@cybr)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/update-sitemap-programmatically/#post-15537095)
 * Howdy!
 * You can use `function_exists( 'tsf' ) and tsf()->delete_cache( 'sitemap' );`.
 * Here you can find an example of TSF doing so internally once permalinks are updated:
   [https://github.com/sybrew/the-seo-framework/blob/4.2.3/inc/classes/cache.class.php#L364-L381](https://github.com/sybrew/the-seo-framework/blob/4.2.3/inc/classes/cache.class.php#L364-L381).
   This method’s action hook registration is at line 49.
 * I hope this helps! Cheers 🙂
 *  Thread Starter [robertrosanke](https://wordpress.org/support/users/robertrosanke/)
 * (@robertrosanke)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/update-sitemap-programmatically/#post-15537167)
 * This works right away.
 * Appreciate your help.
    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Update sitemap programmatically’ is closed to new replies.

 * ![](https://ps.w.org/autodescription/assets/icon.svg?rev=3000376)
 * [The SEO Framework – Fast, Automated, Effortless.](https://wordpress.org/plugins/autodescription/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autodescription/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autodescription/)
 * [Active Topics](https://wordpress.org/support/plugin/autodescription/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autodescription/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autodescription/reviews/)

## Tags

 * [cache](https://wordpress.org/support/topic-tag/cache/)
 * [sitemap](https://wordpress.org/support/topic-tag/sitemap/)

 * 3 replies
 * 2 participants
 * Last reply from: [robertrosanke](https://wordpress.org/support/users/robertrosanke/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/update-sitemap-programmatically/#post-15537167)
 * Status: resolved