• Resolved bluesix

    (@bluesix)


    We have an archive-style page that have included in its own sitemap under Sitemaps > Additional Pages. However we need to update the page’s Last Modified timestamp whenever we published new content into it. The page is not a physical WP page, rather a dynamic, custom archive-style template.

    Is there a way to update the Last Modified value of that page in the sitemap programmatically?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author arnaudbroes

    (@arnaudbroes)

    Hey @bluesix,

    I would remove the additional page from our UI and instead insert it programmatically using our aioseo_sitemap_additional_pages filter hook. That way you can make sure it always has the latest modified date – https://aioseo.com/docs/aioseo_sitemap_additional_pages/

    Let me know if you have any other questions!

    Thread Starter bluesix

    (@bluesix)

    Ah, that’s exactly what I was looking for, thank you!

    Thread Starter bluesix

    (@bluesix)

    Having trouble implementing this.

    I have a pre_post_update hook which gets called when a post gets update/added, and inside that function, I’m calling the aioseo_sitemap_additional_pages filter function. My URL isn’t getting added to the additional pages list. (I have Additional Pages ON). Inside the aioseo_sitemap_additional_pages filter I’m calling error_log to confirm if it’s getting called, but nothing is getting written to the log. Should it be an action?

    // called inside my 'pre_post_update' hook
    add_filter( 'aioseo_sitemap_additional_pages', 'aioseo_sitemap_add_additional_pages' );		
    
    function aioseo_sitemap_add_additional_pages( $pages ) {
      error_log(print_r('filter called', true)); // nothing getting written to debug log
      $pages[] = [
        'loc'        => 'https://www.[domain].com/our-listings/property/',
        'lastmod'    => Date('Y-m-d H:i:s'),
        'changefreq' => 'daily',
        'priority'   => 0.8
      ];
     return $pages;
    }
    • This reply was modified 1 year ago by bluesix.
    Plugin Author arnaudbroes

    (@arnaudbroes)

    Hey @bluesix,

    It’s a filter; not an action. The code snippet you wrote looks fine to me.

    Are you visiting the sitemap to test this? The filter will only be applied when the sitemap is generated – it doesn’t run in the UI/sitemap settings menu. So, the page will be added directly to the additional pages sitemap index but it won’t appear inside of the UI.

    Thread Starter bluesix

    (@bluesix)

    Ahh, cool, yes it’s working when I view the sitemap index page. Had assumed it would get added into the dashboard admin, which is what confused me about using a filter. Thanks for the explanation!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Update Sitemap > Additional Page Last Mod timestamp programmatically?’ is closed to new replies.