Skip to content

Instantly share code, notes, and snippets.

@aristidesneto
Last active February 29, 2020 10:39
Show Gist options
  • Save aristidesneto/953ae9562865c7f903f24d0415a92e52 to your computer and use it in GitHub Desktop.
Save aristidesneto/953ae9562865c7f903f24d0415a92e52 to your computer and use it in GitHub Desktop.
// Gera o arquivo XML do sitemap
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>'.HOME.'</loc>
<lastmod>'.$date.'</lastmod>
<changefreq>weekly</changefreq>
<priority>1.00</priority>
</url>';
foreach($rows as $v){
$datetime = new DateTime($v['updated_at']);
$date = $datetime->format(DateTime::ATOM);
$xml .='
<url>
<loc>'.HOME.'/'.$v['slug'].'</loc>
<lastmod>'.$date.'</lastmod>
<changefreq>weekly</changefreq>
<priority>0.85</priority>
</url>';
}
$xml .= '
</urlset>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment