Tutorial: Write a Sitemap Plugin Day 8

Today I complete two easy tasks:

  • intercept the URL http://www.myblog.com/sitemap.xml 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:

http://www.google.com/webmasters/sitemaps/ping?sitemap=sitemapurl

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

The final version of sitemap: Sitemap 1.1.2 (399)

Do not forget to comment this lesson!
Insertion provided by Post Layout Pro of code on single post.

One Response to “Tutorial: Write a Sitemap Plugin Day 8”

  1. 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 solution.im very newby in wordpress.Thanks in advance.

Leave a Reply