<?php
require_once 'config/db.php';
header("Content-Type: application/xml; charset=utf-8");

echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

$posts = $pdo->query("SELECT slug,updated_at FROM blog_posts WHERE status='published'")->fetchAll();

foreach($posts as $post){
    echo "<url>
        <loc>https://fetrealtytax.com/blog/".$post['slug']."</loc>
        <lastmod>".date("Y-m-d", strtotime($post['updated_at']))."</lastmod>
    </url>";
}

echo '</urlset>';