WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Not sure if this helps, but I use an events plugin and generate my old sitemaps for the events as a standalone sitemap and use the Google XML Sitemaps plugin for my posts/pages/cats, etc. I can share that code if you're interested – TomC Apr 2 '14 at 13:07
Yes please, it's maybe a better solution to have 2 different sitemaps. – Pietro Apr 2 '14 at 14:09
You can find it here: e-dynamics.be/bbpress/topic.php?id=1801 – TomC Apr 3 '14 at 7:19
up vote 1 down vote accepted

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;
share|improve this answer

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'] );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.