<?xml version="1.0" encoding="UTF-8"?>
<!-- qc62.com sitemap.xml
     部署：放到网站根目录，访问 https://qc62.com/sitemap.xml
     维护：每新增页面/文章，加一段 <url>；建议改为 WordPress 自动生成（见下方说明）。 -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://qc62.com/</loc>
    <lastmod>2026-08-27</lastmod>
    <changefreq>weekly</changefreq>
    <priority>1.0</priority>
  </url>
  <!-- 真实文章页示例（按你站点实际 slug 补充）：
  <url>
    <loc>https://qc62.com/your-post-slug</loc>
    <lastmod>2026-08-27</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.8</priority>
  </url>
  -->
</urlset>

<!-- ============================================================
     不新增插件，用"必须使用的插件(mu-plugin)"自动生成 sitemap + canonical
     做法：把下方代码保存为  wp-content/mu-plugins/seo-basic.php
           （mu-plugins 目录若不存在自行新建，无需在后台启用，自动生效）
     作用：自动输出 canonical 标签 + 一个动态 sitemap（/sitemap.xml 或 /?sitemap=1）
     ============================================================
<?php
/*
  Plugin Name: SEO Basic (mu-plugin, no UI)
  Description: 自动输出 canonical + 动态 sitemap，不新增后台插件、不改业务代码
*/
if (!defined('ABSPATH')) exit;

// 1) 自动 canonical 标签（修正重复内容，集中权重）
add_action('wp_head', function(){
    $url = '';
    if (is_front_page() || is_home()) {
        $url = home_url('/');
    } elseif (is_singular()) {
        $url = get_permalink();
    } elseif (is_category() || is_tag() || is_tax()) {
        $url = get_term_link(get_queried_object());
    } elseif (is_archive()) {
        $url = get_post_type_archive_link(get_post_type());
    } else {
        $url = home_url(add_query_arg(null, null));
    }
    if ($url && !is_wp_error($url)) {
        echo '<link rel="canonical" href="' . esc_url($url) . '" />' . "\n";
    }
}, 5);

// 2) 极简动态 sitemap（覆盖根目录 sitemap.xml；如需纯静态文件可删掉此段，用根目录 sitemap.xml 即可）
add_action('init', function(){
    if (isset($_GET['sitemap']) && $_GET['sitemap'] === '1') {
        header('Content-Type: application/xml; charset=utf-8');
        echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
        echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
        // 首页
        echo '  <url><loc>' . esc_url(home_url('/')) . '</loc><changefreq>weekly</changefreq><priority>1.0</priority></url>' . "\n";
        // 文章/页面
        $posts = get_posts(['post_type'=>['post','page'],'post_status'=>'publish','numberposts'=>500]);
        foreach ($posts as $p) {
            $loc = get_permalink($p);
            $mod = get_the_modified_date('c', $p);
            echo '  <url><loc>' . esc_url($loc) . '</loc><lastmod>' . $mod . '</lastmod><changefreq>monthly</changefreq><priority>0.8</priority></url>' . "\n";
        }
        echo '</urlset>';
        exit;
    }
});
?>
-->
