“Error loading stylesheet: An unknown error has occurred (805303f4)”, that’s the error I get last night when I try to access my sitemap.xml file. After doing some search on google, I notice that this error only happens to me when I access the sitemap with “www.kennyneo.com/sitemap.xml”, and it works perfectly fine if I take away the “www” and access with “kennyneo.com/sitemap.xml”. Spent sometime searching and can’t find any website that give me the solution that I’m looking for, so I decided to dig in myself and solve it.

Google XML Sitemap Error

Google XML Sitemap Error




The main issues is “error loading stylesheet”, isn’t that obvious? After looking at the sitemap.xml source itself, I notice that it is referencing to “http://kennyneo.com/wp-content/plugins/google-sitemap-generator/sitemap.xsl” for the style sheet, I copy and paste that URL on browser, and BANG! I can’t access it. Ok, I’m not going to dig deep to check why I can’t access it with that URL path, I guess we might not be able to import style sheet from “kennyneo.com” when we accessing “www.kennyneo.com”. So the easiest solution is to update the sitemap generator code to use relative path to the stylesheet, instead of full path, relative path meaning I will be accessing the sitemap stylesheet using “wp-content/plugins/google-sitemap-generator/sitemap.xsl”. I’m using Google XML sitemaps by Arne Brachhold, goto your wordpress plugin, and click edit,
Google XML Sitemap Plugin

Google XML Sitemap Plugin

Do you want me to help you setup your Wordpress for FREE? (Drop me an email at kenny@kennyneo.com if you choose "Yes")

View Results

Loading ... Loading ...

Onces you click edit, youshould be able to see a list of files from this plugin available for you to edit, now look for a file named “sitemap-core.php”, and click on that one. Try to look for a function name “GetPluginUrl()”, and it should looks like the following,

Google XML Sitemap Plugin

Google XML Sitemap Plugin




This is the original code,

function GetPluginUrl() {

	//Try to use WP API if possible, introduced in WP 2.6
	if (function_exists('plugins_url')) return trailingslashit(plugins_url(basename(dirname(__FILE__))));

	//Try to find manually... can't work if wp-content was renamed or is redirected
	$path = dirname(__FILE__);
	$path = str_replace("\\","/",$path);
	$path = trailingslashit(get_bloginfo('wpurl')) . trailingslashit(substr($path,strpos($path,"wp-content/")));
	return $path;
}



This is how I would edit the code, just change how it retrieve the URL,

function GetPluginUrl() {

	//Try to use WP API if possible, introduced in WP 2.6
	//if (function_exists('plugins_url')) return trailingslashit(plugins_url(basename(dirname(__FILE__))));

	//Try to find manually... can't work if wp-content was renamed or is redirected
	$path = dirname(__FILE__);
	$path = str_replace("\\","/",$path);
	//$path = trailingslashit(get_bloginfo('wpurl')) . trailingslashit(substr($path,strpos($path,"wp-content/")));
	$path = trailingslashit(substr($path,strpos($path,"wp-content/")));
	return $path;
}



After you have make the changes, click on the “Update File” in wordpress. Goto the Settings -> XML-sitemap and try to rebuild the sitemap, once is done, you should be able to access your sitemap with or without “www”. It works for me, I hope it works for you too. I’m not sure how google spider going to crawl the sitemap, but it always good to have it accesssible in both way. Last, if it doesn’t work for you, drop me a comment. :D