[Plugin: Google XML Sitemaps] Doesn't 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
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~
The topic ‘[Plugin: Google XML Sitemaps] Doesn't support custom post types with dashes’ is closed to new replies.