I was working on a customer site and realised that the Google Sitemap Generator I use wasn’t including the Custom Content Types I had created in WordPress 3.0.
Luckily the original plugin writer (Arne Brachhold) had created a hook to enable the addition of extra pages. Since I couldn’t wait for Arne to catch up, I created this plugin plugin.
The plugin has no additional admin, and will automatically add all your new public custom content types to the sitemap. If you wish to filter out some particular content types you can filter them out using add_filter which you add to the functions.php file in your theme directory:
function my_filter($posttypes) { // to remove posttypes of a particular name foreach($posttypes as $key => $val) { if($val=='super_duper') { unset($posttypes[$key]); } } // to add posttypes e.g. page $posttypes[] = 'page'; return $posttypes; } add_filter('guar_sitemap_posttype_filter','my_filter',10,1);
Note: This doesn’t fix the outstanding Multi-site issue – though I believe Arne is on the case.
Update (1.1): Excluded PostIDs and Categories are now honoured. The download reflects these changes.
Update (1.2): Uses the default Change Frequency for Posts.
Download Plugin: guar_sitemap_1.2

[...] This post was mentioned on Twitter by Mark Sharp, GetupandRunning. GetupandRunning said: New post: Adding Custom Content Types to the Sitemap http://bit.ly/cUaFrA [...]
Thx for your work!
Hi..Help!
I don’t know if your fix will cover this error or not.
Do you know how I fix this one?
thanks in advance, mike
Error loading stylesheet: A network error occured loading an XSLT stylesheet:http://www.mikewiservidz.com/wp-content/plugins/google-sitemap-generator/sitemap.xsl
I added the code to the end of my functions.php, but it didn’t work for me… I changed the word ‘page’ to match my post type name, but nothing happened… I rebuild the map, but it looks the same, nothing was added.
Thanks for the effort, though.
Hi Alice, you need to unzip the guar_sitemap plugin into your plugins directory, and then activate it. This will automatically add your custom content types. The code snippet above is only necessary if you want to further control the content types (e.g. opt certain content types out).
Hi Mike, your issue isn’t related – it looks like the xsl file is missing. You might try uninstalling the google-sitemap-generator plugin and then reinstalling it. Switch off/Switch on – the oldest and best computer fix it tip.
You are awesome!!!
Thanks very much, this does a great job of adding the custom post types.
I know this is intended to be just a temporary stopgap plugin, but just to advise other people that it does override the ‘excluded posts’ option.
You can add the following line at line 58 (before the line with the ORDER BY in it) if this is important for you:
$where.=” AND ID NOT IN (100,101,102)”;
(replacing the numbers with your excluded post IDs of course)
Thanks for you comments Simon. It will only override excludes for any custom content type posts or if you redo posts or pages. It will honour password protected custom content types however.
It wasn’t really part of my requirement, but I will probably update the plugin to honour those excludes. I’ll update the post and download when I have done that.
You can fetch all public post types using the below code snippet, so that you don’t have to run the guar_filter_posttypes at all.
$args=array( 'public' => true, '_builtin' => false ); $output = 'names'; // names or objects $operator = 'and'; // 'and' or 'or' $posttypes=get_post_types($args,$output,$operator);Great work Mark. Love this addition. Il keep my eye out for when its patched in case the two clash when its updated. Loving custom post types in general keep up the good work. Im trying to add scribe seo to the custom post types edit page, any thoughts?
Didn’t work for me
my custom post types still don’t show up in the sitemap.
If you downloaded the plugin and activated it, and have the original Google XML sitemap plugin installed and activated it should work fine. The code example above is only if your wish to further change the sitemap options.
Looks like it might have been a refresh problem on my end. Checked out the XML just now and all my custom entries are now listed. Strange. Anyway, thanks for this plugin!
[...] found a patch here that uses an existing hook in the plugin and seems to work great so [...]
Mate you rock – Thanks for this
Worked beautifully for me. I’d really love if it could also create entries in the sitemap for custom post type archives (based on the taxonomies applied to them). I’ve installed this plugin: http://www.cmurrayconsulting.com/software/wordpress-custom-post-type-archives/ which makes pages like http://www.site.com/movies/ work as well as http://www.site.com/movies/comedy/ – as well as http://www.site.com/movies/caddyshack/
Thanks, Charles
Hello,
Thanks for this nice fix!
Hi Mark,
I had been wondering for the last few days how I would be able to include my ‘Events’ Custom Post Types into my sitemaps. Well, thanks to your nifty little plugin I have an answer.
Many thanks and all has worked beautifully for me.
Regards,
Ray
This plugin worked perfectly for a new WP site I’m setting up. Thanks!
Hi, thanks for sharing. I have used it in my web, I made new wp custom object type for my code snippets.
Brilliant!
Just built a new site with custom post types and this is a great interim solution. Worked first time for me.
thanks!
Peter
Hi
Thanks for this plugin. it worked for me. Nice work done.
Thanks once again
Hello
Thanks for this plugin, it solved my problem. Great job! … Thanks a lot for work …
Renato Rezende
thanks and it worked for me.
however, there is some small issue: for some post_types, the priority is 100%, some are 20%. seems small improvement needs to be done.
Anyway, thanks again for the great work. if updates are out, appreciate if u can keep me posted!
cheers,
hi,
figured out the problem, your plugin is totally fine. i have overlooked sth.
sorry about that. and i have give u credit at the wordpress forum: http://wordpress.org/support/topic/google-sitemap-generator-not-generating-all-posts?replies=4
thanks!
hehe! I do the same so often: ask the question then answer it myself a few minutes later. Glad it’s working for you.
Thanks for this. It’s a massive help and saved us loads of time trying to fix this issue
If the URLs do not appear after activating the plugin, go to administration page XML sitemap generator and click “rebuild the sitemap manually”.
Thanks.
I tried out this plugin, but it did not appear to resolve what I perceive to be a problem.
Here is my sitemap:
http://faithjohnstown.com/sitemap.xml
Here is an example post I was hoping to get included here (from this page http://faithjohnstown.com/resources/sermon-search/):
http://faithjohnstown.com/resources/sermon-search/?sermon_id=86
I’m using the Sermon Search plugin for these posts. I’ve installed and activated the plugin plugin, and told Google XML Sitemaps v3.2.4 to manually rebuild the sitemap page.
Any suggestions? Did I miss something?
Thanks,
Brian
Doh, ignore the extra “)” on the first sermon-search link. Should be:
http://faithjohnstown.com/resources/sermon-search/
Hi Brian,
The issue isn’t to do with Custom Post Types. The sermon plugin doesn’t create any entries in WP’s post table; they’re all in their own table.
All’s not lost though, you can take my plugin and adapt it for your purposes, but instead of retrieving the custom post types and the entries for those types, you would need to create your own query to get the sermon ids and build your own url from there.
Note: because the sermon plugin is controlled via a shortcode on a single page, you would need to find a way to specify which page that shortcode is on, perhaps using the sermon plugin’s option setting in the options table.
Mark,
This probably explains why I can never get any Facebook sharing plugins to work properly with the sermon browser links either.
Thank you for the suggestion, I’ll take a hack at it.
Brian
Yes, that very likely explains why, although with the query parameter it is still a valid url.
Thank you for the direction. A friend of mine who’s more versed in php was able to help me get this working for our site. It isn’t a real pretty hack, but it will work for me.
http://faithjohnstown.com/sitemap.xml
Thanks Mark! Your work is greatly appreciated.
I want to have your babies! Thank you so much for this.
http://www.tutorialvideoz.com now has a sexy working sitemap thanks you to!
Thanks man, you’re live safer!
Great addition to the plugin!!
Keep it up.
Greetings,
FotoForward.nl
Thank you…. Hopefully Google Sitemps add your code!!!
wow great ..
it is wonderful plugin ..
I’m tring to solve the problem. but it was very easy when I use the plugin .. Thank you very very very much ^^
Thank you very much Mark ! Your plugin saves me a lot of time !
Hi all my custom post type posts seem to have a priority of 20%. Is there a way to fix this?
Oops, sorry fixed it. Had to raise the “minimum post priority” from .2.
Hi Mark,
Thanks for your efforts, Finally google xml sitemap works with your plugin.
Thanks for your efforts.
I installed the plugin but the link (XML Sitemap) in the settings menu does not appear. I tried accessing it by using the url wp-admin/options-general.php?page=google-sitemap-generator/sitemap.php but it said “You do not have sufficient permissions to access this page.” I’m running WordPress 3.1.
Any ideas?
Hi Dave, Do you have Arne’s plugin installed as well? My plugin works with his plugin, it doesn’t replace it. My plugin doesn’t add anything to the admin menu.
Mark
Installed and works perfect!
Thank you Goog for helping me find this
Thank you Mark for this plugin
Nice work!
Great! Exactly what i was looking for.. the searching was a lot harder than installing the solution
Great fix! You saved the day! Thank you!
My sitemap dont show all pages before. Thanks it work fine.
Hi Mark,
I am getting the following error when I activate your plugin and try rebuilding the sitemap, I have over 500 custom posts, Would that be causing any problem??
The last run didn’t finish! Maybe you can raise the memory or time limit for PHP scripts. Learn more
The last known memory usage of the script was 15.75MB, the limit of your server is 256M.
The last known execution time of the script was 0.02 seconds, the limit of your server is 120 seconds.
The script stopped around post number 4 (+/- 100)