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!
Ah, that’s exactly what I was looking for, thank you!
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 2 years, 7 months ago by
bluesix.
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.
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!