Support » Plugin: All in One SEO Pack » Dynamic Sitemap Generation Hook

  • Resolved decit



    Besides the urls of posts, pages and categories, I need my site’s sitemap to include the urls of various pages that display data coming from a source other than the WP database.

    Is there a hook to which I can add a filter so that once Dynamic Sitemap Generation takes place, I can then append these other urls I’m talking about?

    Thanks a lot for this amazing amazing AMAZING plugin!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Steve Mortiboy


    Support Manager at Semper Fi

    Hi itdge,

    Our XML Sitemap module has a field for this, you can find it under All in One SEO, XML Sitemap, Additional Pages. How many URLs do you want to add?


    At the moment I cannot check the field as I’m not in the office.
    However the urls grow with time:
    I have a WP website that besides WP content has to serve pages dynamically generated out of data fetched from a REST API ( all of this is done by a plugin I wrote ).
    I need the URL’s of these pages to be in the sitemap, thus I need to “complete” the sitemap generated programmatically and not by hand.

    Do you have any idea on how my plugin could detect that All in One SEO has finished updating the sitemap?

    Plugin Contributor Peter Baylies


    Hi itdge,

    The sitemap module has a number of hooks that you might find useful here; the aiosp_sitemap_post_filter hook will give you access to the raw post data returned while the sitemap is being built, so you’d be able to inject your own content here. There’s also a aiosp_sitemap_post_query hook that would let you modify the query before it runs (it sounds like you wouldn’t need to do this, but it is available). In addition, the module itself uses a number of hooks in the sitemap generation process, so it might be possible to customize the process further if need be. We will also be adding more hooks to add more specific functionality to customize the sitemap in future releases.

    Hi Peter,
    how can I append my content to the sitemap.xml using the aiosp_sitemap_post_filter hook?

    Thank you for your help!

    It seems to me that you can add only other posts with this hook. I need to add or create a separate sitemap, with custom data that aren’t posts.
    An hook to add ‘loc’, ‘lastmod’, ‘priority’ and ‘changefreq’.

    Plugin Contributor Peter Baylies


    Hi Itdge,

    If you have items that aren’t posts at all, it might be easier to use the option_aioseop_options filter to add items to the additional pages on the fly. Here’s some sample code for you:

    add_filter( 'option_aioseop_options', 'itdge_sitemap_addl_pages' );
    function itdge_sitemap_addl_pages( $option ) {
    	if (   !empty( $option )
    		&& !empty( $option['modules'] )
    		&& !empty( $option['modules']['aiosp_sitemap_options'])
    	  ) {
    		$my_sitemap_entries = Array(
    		'/test1' => Array( 'prio' => '0.1', 'freq' => 'daily', 'mod' => '2014-04-01' ),
    		'/test2' => Array( 'prio' => '0.3', 'freq' => 'weekly', 'mod' => '2014-03-02' )
    		if ( empty( $option['modules']['aiosp_sitemap_options']['aiosp_sitemap_addl_pages'] ) ) {
    			$option['modules']['aiosp_sitemap_options']['aiosp_sitemap_addl_pages'] = Array();
    		foreach( $my_sitemap_entries as $k => $v ) {
    			$option['modules']['aiosp_sitemap_options']['aiosp_sitemap_addl_pages'][$k] = $v;
    	return $option;


Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Dynamic Sitemap Generation Hook’ is closed to new replies.