Hook to generate a dynamic sitemap with “All in One SEO Pack” Plugin

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 an external source other than the WP database (Rails API).

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 to the sitemap.

PS: I had a suggestion to use aiosp_sitemap_post_filter, but there is no doc on how it works.



with aiosp_sitemap_post_filter you can add only other posts to the sitemap and no custom content.

Solutions Collecting From Web of "Hook to generate a dynamic sitemap with “All in One SEO Pack” Plugin"

This is the solution from Peter Baylies (Plugin Author)

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;

This is not a solution to my question but it helps me to solve my problem in WordPress, and I want to share it.

I create a separate sitemap using XMLWriter. Here is the code.

WordPress hook:

add_action('parse_request', 'my_custom_url_handler');

function my_custom_url_handler() {
    $c = new EventsSitemapBuilder();
    if( $_SERVER["REQUEST_URI"] == '/website/events-sitemap.xml') {
        header("Content-type: text/xml");
        $c = new EventsSitemapBuilder();


class EventsSitemapBuilder {

        private $api_client;
        private $sitemap_data;
        private $sm_xml_writer;

        public function __construct() {
            $this->api_client = new ALApiClient();
            $this->sitemap_data = $this->api_client->sitemap_data();
            $this->sm_xml_writer = new XMLWriter();

        public function build() {
            //events.id, it_texts.slug AS it_slug, en_texts.slug AS en_slug, events.updated_at
            //$this->sm_xml_writer->openUri( home_url( "events-sitemap" ) );
            $this->sm_xml_writer->openUri( "php://output" );
            $this->sm_xml_writer->startDocument('1.0', 'UTF-8');
            $this->sm_xml_writer->writeAttribute('xmlns', "http://www.sitemaps.org/schemas/sitemap/0.9");

            array_map( array( $this, 'sitemap_event_entry' ), $this->sitemap_data );


        private function sitemap_event_entry( $data ) {
            $this->sm_xml_writer->writeElement('lastmod', $data['date']);
            $this->sm_xml_writer->writeElement('changefreq', 'weekly');
            $this->sm_xml_writer->writeElement('priority', 0.6);
            $event_url = home_url( 'events/' . $data['id']  );
            $this->sm_xml_writer->writeElement('loc', $data['url'] );