Adding Custom Post Types to Sitemap

The Google Sitemap Generator WordPress Plugin is the most widely used plugin to generate a sitemap for a wordpress site. However it doesn’t support custom types yet. Hence the Google Bot hasn’t been visiting my website as frequently coz the sitemap doesn’t have the posts I add on my custom microblog. So I modified the plugin to add support for all public non-built-in post types. Here’s the patch.

To apply the patch, go to the folder of the google sitemap generator plugin ROOTDIR/wp-content/plugins/google-sitemap-generator and execute the below command.

zcat sitemap.patch.gz | patch -p0

Do make sure you specify the correct path for sitemap.patch.gz.

If you want a more elegant solution, go here. I found it after I wrote the patch :(.

I’m adding it directly to the plugin code, hoping that the next release of the plugin would bring support for custom post types and I won’t have to worry about the patch being overwritten.

About Pratik Sinha

Linux Nerd, Socialist, Atheist, Adventuristic, Nature Lover, Geeky.

1 comment

  1. It’s strange that the sitemaps including the top level custom post type, but none of the children…

    This worked perfectly! I’m making a glossary for my website and couldn’t get any of the words to get into the sitemap.

    Thanks!

Leave a Reply