Last active
February 29, 2020 10:39
-
-
Save aristidesneto/953ae9562865c7f903f24d0415a92e52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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