If you are using the sitemap plugin for Wordpress from Arne Brachhold, you may have the need to add additional pages which are not generated by your blog. If you’ve got a handful of pages, the sitemap plugin gives your the possibility to add them manually through the option page. There is also an option that allows the plugin to build the sitemap based on requests sent to your web server.
This may be useful but if you need a little more control, here’s how to dynamically add pages to your Wordpress sitemap:
1. Edit /wp-content/plugins/google-sitemap-generator/sitemap.php
2. Find the line that reads:
$this->AddElement(new GoogleSitemapGeneratorXmlEntry(”</urlset>”));
3. Just before this line, insert:
include(”mysitemap.php”);
4. Create a new empty file into /wp-content/plugins/google-sitemap-generator/ and save it as mysitemap.php.
5. Insert the following content into your newly created file:
<?php
$this->AddElement(new GoogleSitemapGeneratorXmlEntry(” <url>”));
$this->AddElement(new GoogleSitemapGeneratorXmlEntry(”\n <loc>http://www.yourdomain.com/document.html</loc>”));
$this->AddElement(new GoogleSitemapGeneratorXmlEntry(”\n <changefreq>weekly</changefreq>”));
$this->AddElement(new GoogleSitemapGeneratorXmlEntry(”\n <priority>0.5</priority>”));
$this->AddElement(new GoogleSitemapGeneratorXmlEntry(”\n </url>\n”));
?>
6. Once your done, upload sitemap.php and mysitemap.php to your web server.
Of course the iteration process has to occur between the <url> and </url> entries (the part identified in red). You can dynamically add pages using an SQL query for example.
The sitemap.xml and sitemap.xml.gz files will automatically be updated with your dynamic entries next time your rebuild your sitemap.








Top Commentators