Title: [Plugin: Google XML Sitemaps] Doesn&#039;t support custom post types with dashes
Last modified: August 20, 2016

---

# [Plugin: Google XML Sitemaps] Doesn't support custom post types with dashes

 *  [Matthew Boynes](https://wordpress.org/support/users/mboynes/)
 * (@mboynes)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-google-xml-sitemaps-doesnt-support-custom-post-types-with-dashes/)
 * I’ve just started using this plugin (4.0beta8) and I’ve noticed it relies heavily
   on dashes — unfortunately, if your custom post type has dashes in it, they don’t
   show up in XML files. This specifically happens in `GoogleSitemapGeneratorStandardBuilder::
   BuildPosts()` here:
 *     ```
       if(!$pts = strpos($params, "-")) return;
       $postType = substr($params, 0, $pts);
       ```
   
 * If my post type is featured-projects then $postType becomes ‘featured’.
 * To fix this, I’ve changed this method from:
 *     ```
       if(!$pts = strpos($params, "-")) return;
   
       $postType = substr($params, 0, $pts);
   
       if(!in_array($postType, $gsg->GetActivePostTypes())) return;
   
       $params = substr($params, $pts + 1);
   
       global $wp_version;
   
       if(preg_match('/^([0-9]{4})\-([0-9]{2})$/', $params, $matches)) {
       	$year = $matches[1];
       	$month = $matches[2];
       	# ... lots of other code...
       }
       ```
   
 * to:
 *     ```
       if (!preg_match('/^(.*)-(\d{4})-(\d{2})$/', $params, $matches)) return;
   
       $postType = $matches[1];
   
       if(!in_array($postType, $gsg->GetActivePostTypes())) return;
   
       global $wp_version;
   
       $year = $matches[2];
       $month = $matches[3];
       # ... lots of other code...
       ```
   
 * Here is a gist of the full file: [https://gist.github.com/1775697](https://gist.github.com/1775697)
 * Thus far, this has resolved this issue for me. However, since dashes are relied
   upon in other places, I would wage that there are other similar issues elsewhere
   in the plugin. Please let me know if I can be of any assistance in resolving 
   any other issues.
 * Cheers~
 * [http://wordpress.org/extend/plugins/google-sitemap-generator/](http://wordpress.org/extend/plugins/google-sitemap-generator/)

The topic ‘[Plugin: Google XML Sitemaps] Doesn't support custom post types with 
dashes’ is closed to new replies.

 * ![](https://ps.w.org/google-sitemap-generator/assets/icon-256x256.png?rev=2713572)
 * [XML Sitemap Generator for Google](https://wordpress.org/plugins/google-sitemap-generator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-sitemap-generator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-sitemap-generator/)
 * [Active Topics](https://wordpress.org/support/plugin/google-sitemap-generator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-sitemap-generator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-sitemap-generator/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Matthew Boynes](https://wordpress.org/support/users/mboynes/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-google-xml-sitemaps-doesnt-support-custom-post-types-with-dashes/)
 * Status: not resolved