携帯サイトとしてgoogleに認識されるようになったっぽい | のぶじゃすBLOGってエントリーを昨日寝る直前に布団の中で書いたので、方法を書きます。
のぶじゃすBLOGではGoogle (XML) Sitemaps Generator for WordPressというプラグインを使っているのですが、そのプラグインでモバイル対応する方法を書きます。
内容は以下
基本的な内容はモバイル サイトマップの作成 – ウェブマスター ツール ヘルプに書いてあります。
wp/wp-content/plugins/google-sitemap-generator/sitemap-core.php
を編集するだけで出来ます。
diffを貼っておきます。
Index: sitemap-core.php
===================================================================
--- sitemap-core.php (リビジョン 572)
+++ sitemap-core.php (作業コピー)
@@ -402,6 +402,7 @@
if($this->_lastMod>0) $r.= "\t\t<lastmod>" . date('Y-m-d\TH:i:s+00:00',$this->_lastMod) . "</lastmod>\n";
if(!empty($this->_changeFreq)) $r.= "\t\t<changefreq>" . $this->_changeFreq . "</changefreq>\n";
if($this->_priority!==false && $this->_priority!=="") $r.= "\t\t<priority>" . number_format($this->_priority,1) . "</priority>\n";
+ $r.= "\t\t<mobile:mobile/>\n";
$r.= "\t</url>\n";
return $r;
}
@@ -1669,7 +1670,7 @@
}
//Go XML!
- $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'));
+ $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0">'));
$home = get_bloginfo('url');
要するに、
- </url>の前に<mobile:mobile/>を追加。
- <urlset の中にxmlns:mobile=”http://www.google.com/schemas/sitemap-mobile/1.0″を追加
するだけです。
あ、あとGoogleウェブマスターツール設定しないとダメですよw
おわり。


