Quantcast
Viewing all articles
Browse latest Browse all 3201

radgh on "[Plugin: Google XML Sitemaps] [Bug] Sitemap.xml does not match "is_feed()", causes plugin issues"

I had an issue where my sitemap.xml was blank on various sites. Everything was set up properly though. I discovered that with only this plugin enabled, it worked. As I enabled plugins, I found a few culprits that caused errors.

After thorough debugging, I discovered that all of the issue-causing plugins could have avoided the issue if this plugin had set the main query to be treated as a feed. It should be, too, as this is an xml feed.

Here is my own solution (hack), added to functions.php:

// Fix for XML sitemap not being treated as a "feed", causing plugin conflicts.
// http://wordpress.org/support/topic/bug-sitemapxml-does-not-match-is_feed-causes-plugin-issues?replies=1#post-5474598

function xml_sitemap_into_feed($query) {
  if ( preg_match('/sitemap.*\.(xml|html)$/i', $_SERVER['REQUEST_URI']) ) {
    $query->is_feed = true;
  }

  return $query;
}
add_action('parse_query', 'xml_sitemap_into_feed');

Can this be (properly) implemented into the main plugin so that the sitemap is considered a feed? It should be treated as one.

You can reproduce the error by installing SEO Ultimate. Note that I do not vouch for SEO Ultimate, and I do not even recommend it (it's very bloated and slow). It is used by our client, however.

https://wordpress.org/plugins/google-sitemap-generator/


Viewing all articles
Browse latest Browse all 3201

Trending Articles