Tutorial: Write a Sitemap Plugin Day 8

Today I complete two easy tasks:

  • intercept the URL to serve the sitemap (it will work only with WordPress on Apache and permalink active)
  • ping Google when something happens in WordPress (eg. a post changed)

The two modifications are very easy. The first is a matter to do a little parsing of request uri:

substr($_SERVER[‘REQUEST_URI’], strlen($_SERVER[‘REQUEST_URI’])-11) == ‘sitemap.xml’

and to add a checkbox in the options panel to enable this feature.

The second, ping Google, it’s easy too, but for sake of semplicity, I wrote it to work only on WordPress 2.7 (which has some new libraries).

Google can be pinged for a news sitemap calling:

and the call is made using wp_remote_get (a special function of WordPress).

The final version of sitemap: [download id=”12″]

2 replies on “Tutorial: Write a Sitemap Plugin Day 8”

Hello, I recently graduated with my Master’s in English at Middle Tennessee State University. I am setting up my website to display my portfolio and I am looking for examples of my editing skills. While working on my footer for my site I came across your plugin and user manual. I also see your apologies for your English. Would you be interested in my editing your manual, both for your benefit, and mine, if you will let me display the example on my site? My website is

I have installed the plugin but whenever i click on the sitemap from settings it shows an error
Object not found
“Error 404”

pls provide me a very newby in wordpress.Thanks in advance.

Leave a Reply