TIF_NGANJUK_E41210577/sitemap-post.php

31 lines
946 B
PHP

<?php
header("Content-Type: text/xml; charset=UTF-8");
// Koneksi ke database
require_once("koneksi.php");
// Mulai output XML
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
// **2. Peta Situs untuk artikel detail (slug)**
$sql = "SELECT slug, updated_at FROM detail_artikel ORDER BY updated_at DESC";
$result = $conn->query($sql);
echo '<url>';
echo '<loc>' . htmlspecialchars("https://portalumkm.com/blog/") . '</loc>';
echo '<lastmod>' . date('Y-m-d') . '</lastmod>';
echo '<priority>1.0</priority>';
echo '</url>';
while ($row = $result->fetch_assoc()) {
echo '<url>';
echo '<loc>' . htmlspecialchars("https://portalumkm.com/blog/" . $row['slug']) . '</loc>';
echo '<lastmod>' . date('Y-m-d', strtotime($row['updated_at'])) . '</lastmod>';
echo '<priority>1.0</priority>';
echo '</url>';
}
echo '</urlset>';
$conn->close();
?>