query($sqlCount)->fetch()['c']; $totalPages = max(1, (int)ceil($total / $CHUNK_SIZE)); // best effort: lastmod for static sitemap using local file if available $nowIso = gmdate('c'); $staticLastmod = $nowIso; $localStaticPath = __DIR__ . '/sitemap.xml'; if (is_file($localStaticPath)) { $staticLastmod = gmdate('c', filemtime($localStaticPath)); } echo '', "\n"; echo '', "\n"; // 1) include your existing static sitemap as-is echo " \n"; echo " {$STATIC_SITEMAP_URL}\n"; echo " {$staticLastmod}\n"; echo " \n"; // 2) include dynamic blog sitemaps (paginated) for ($i = 1; $i <= $totalPages; $i++) { $loc = $SITE_BASE . "/sitemap-posts.php?page={$i}"; echo " \n"; echo " {$loc}\n"; echo " {$nowIso}\n"; echo " \n"; } echo "";