風車

你的 WordPress 博客还在使用 XML Sitemap 插件吗?

向搜索引擎提交 sitemap 是快速提高网站收录的最好方法之一,2022年了,你的 WordPress 博客还在使用 XML Sitemap 插件吗?比如还在使用免费人气插件 Google XML Sitemaps 插件自动生成 sitemap.xml 站点地图?

Google XML Sitemaps 带匿名统计代码?

Google XML Sitemaps 确实带匿名统计代码:

代码在 sitemap-core.php 文件中:

/**
* Sends anonymous statistics (disabled by default)
*/
private function SendStats() {
global $wp_version, $wpdb;
$postCount = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} p WHERE p.post_status='publish'");

//Send simple post count statistic to get an idea in which direction this plugin should be optimized
//Only a rough number is required, so we are rounding things up
if($postCount <=5) $postCount = 5;
else if($postCount < 25) $postCount = 10;
else if($postCount < 35) $postCount = 25;
else if($postCount < 75) $postCount = 50;
else if($postCount < 125) $postCount = 100;
else if($postCount < 2000) $postCount = round($postCount / 200) * 200;
else if($postCount < 10000) $postCount = round($postCount / 1000) * 1000;
else $postCount = round($postCount / 10000) * 10000;

$postData = array(
"v" => 1,
"tid" => "UA-65990-26",
"cid" => $this->GetOption('i_hash'),
"aip" => 1, //Anonymize
"t" => "event",
"ec" => "ping",
"ea" => "auto",
"ev" => 1,
"cd1" => $wp_version,
"cd2" => $this->GetVersion(),
"cd3" => PHP_VERSION,
"cd4" => $postCount,
"ul" => get_bloginfo('language'),
);

$this->RemoteOpen('http://www.google-analytics.com/collect', 'post', $postData);
}

不过这功能默认是关闭的,插件设置选项中可以看到:

WordPress 5.5 版本起 内置 sitemap 功能

如果担心隐私问题,不妨使用 WordPress 内置 XML Sitemaps 功能替换 Google XML Sitemaps 插件。

WordPress 5.5 版本开始,核心代码已经内置 XML Sitemaps 功能,只要访问:https://网站地址/wp-sitemap.xml 就能得到当前站点的站点地图,比如 風車 站点 wp-sitemap.xml:https://ae.mba/wp-sitemap.xml

更详细教程参考:使用 WordPress 内置 XML Sitemaps 站点地图以及简单增强优化