修正Google对网站地图的报错,添加更新日期
add_filter('wp_sitemaps_posts_entry', function ($entry, $post) {
$entry['lastmod'] = get_gmt_from_date($post->post_modified, 'Y-m-d\TH:i:s\Z');
return $entry;
}, 10, 2);
add_filter('wp_sitemaps_posts_entry', function ($entry, $post) {
$entry['changefreq'] = 'weekly';
return $entry;
}, 10, 2);
修改默认的robots.txt
add_action('do_robots', function () {
// 定义你的自定义 robots.txt 内容
header('Content-Type: text/plain; charset=utf-8');
echo "User-agent: *\n";
echo "Disallow: /wp-admin/\n";
echo "Disallow: /wp-admin/admin-ajax.php\n";
echo "Disallow: /wp-login.php\n";
echo "Disallow: /wp-content/*\n";
echo "Disallow: /users/*\n";
echo "Disallow: /author/*\n";
echo "Disallow: /tastream/*\n";
echo "Sitemap: " . site_url('/sitemap.xml') . "\n";
});
快整rss