Google Sitemaps with WordPress

I spent a little time and worked up some php code that generates a Google Sitemap from a WordPress site. The php code generates a Google Sitemap xml file with all your posts ordered by time – newest posts first. Here’s a link to my Google Sitemap so you can see how it looks.

I’m sure there are ways to improve on my code so go right ahead. If you do, just leave me a comment. I might want to download it from you.

Just copy this code into a php file.

You can refer back to my previous post to read more about the Google Sitemaps Protocol and how you can submit your Google Sitemap.

Update: Wanted to point out that this generates a Google Sitemap from all your posts. There is no page support or category support. It is real basic and can definitely be improved.

Update #2: I won’t be writing a plugin for this since Arne Brachhold has already written a great one. Thanks Arne.

Recent Posts

Leave a Comment