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

Hey – thanks so much for this fix! I know the original Google XML Sitemaps now has support for Custom Post Types in the beta version, but my client needed this now.
Very cool of you to write and release this. Muchas Gracias, Amigo mio!
Still working like a charm, thanks a lot!
thanks! worked like a charm
Hi,
thanks for the code, you might be also interested in a function like this to exclude private post types automatically
( note gode is not tested yet) :
function custom_exclude_non_public($post_types) { $custom_post_types = get_post_types(array( '_builtin' => false ), 'objects', 'and' ); $keys = array_flip($post_types); if(!is_null($keys)) { foreach($custom_post_types as $custom_post_type) { if($custom_post_type->publicly_queryable === false || $custom_post_type->exclude_from_search === true) { $key = $keys[$custom_post_type->name]; unset($post_types[$key]); } } } } add_filter('guar_sitemap_posttype_filter','custom_exclude_non_public',50,1);@serge, thanks for that, that’s what the filter is for.
Doesn’t appear to work with WordPress 3.2.1 and XML Sitemap Generator 3.2.6 – Same results as without your plugin activated.
Any thoughts?
Hi Matt, just tested WP 3.2.1 and the generator 3.2.6 and it works fine. You may need to run a manual sitemap generation from the admin panel for the first time – when you create a new post, this should update automatically.
Hi, just tested the code here http://thesistut.com/
it was buggy, here is the fixed version :
function custom_exclude_non_public($post_types = array()) { $custom_post_types = get_post_types(array( '_builtin' => false ), 'objects', 'and' ); $keys = array_flip($post_types); if(!is_null($keys)) { foreach($custom_post_types as $custom_post_type) { if($custom_post_type->publicly_queryable === false || $custom_post_type->exclude_from_search === true) { $key = $keys[$custom_post_type->name]; unset($post_types[$key]); } } } return $post_types; } add_filter('guar_sitemap_posttype_filter','custom_exclude_non_public',50,1);I have a question is there any way to apply same priority to custom post types as to posts?
sorry, found that in the code
Self-help is marvelous! Thanks for the little update on your filter.