Jan
30
Google Sitemaps on Wordpress-MU Platform
January 30, 2010 | Leave a Comment
Have you tried to get Google Sitemaps running on a Wordpress-Mu platform? There are a few sitemap plugins available, but the problem is that all of the plugins I could find put the sitemap.xml file in the Wordpress mu install directory. The generated sitemap is useful for the primary blog, but not for the subdomain blogs or the subdirectory blogs.
During my research, I came across the famous sitemap generator plugin for wordpress called Google (XML) Sitemaps Generator for WordPress. It can allow you to easily generate Google XML SiteMap within your blog. But unfortunately the last version I found was not developed for WordPress MU, either. By default, it could only generate the XML sitemap for the primary blog, not all other blogs in your WordPress MU. That was not enough for me as I had to register all my blogs with the search engines.
I finally came across an interesting article which explains how easy it is to change the code within the Sitemap Generator for Wordpress in order to make it generate sitemaps for various blogs installed on a Wordpress Mu platform.
You first download the Google XML Sitemaps Generator for WordPress plugin.
You then edit the sitemap-core.php file in the plugin’s folder, and make the following changes:
In the function “GetXmlUrl”, line 1351, change to:
| 1351 1352 1353 1354 1355 1356 1357 1358 |
function GetXmlUrl($forceAuto=false) { if(!$forceAuto && $this->GetOption(“b_location_mode”)==“manual”) { return $this->GetOption(“b_fileurl_manual”); } else { return trailingslashit(get_bloginfo(’siteurl’)) . ‘files/’ . $this->GetOption(“b_filename”); } } |
and in the GetXmlPath function, line 1382, change to:
| 1382 1383 1384 1385 1386 1387 1388 1389 |
function GetXmlPath($forceAuto=false) { if(!$forceAuto && $this->GetOption(“b_location_mode”)==“manual”) { return $this->GetOption(“b_filename_manual”); } else { wp_mkdir_p(ABSPATH . UPLOADS); return ABSPATH . UPLOADS . $this->GetOption(“b_filename”); } } |
This change makes that from now on, the sitemap files will be stored on a per blog basis, inside the blog’s uploads folder.
Upload your modified plugin into the plugins folder, activate it as usual and rebuild your sitemap for each of your blogs.
I am happy to have come across this article. It works and that’s why I had to share it with you.