PHP code example of prolificrohit / sitemaps
1. Go to this page and download the library: Download prolificrohit/sitemaps library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
prolificrohit / sitemaps example snippets
$sitemap = new Sitemap("sitemaps/test.xml");
$sitemap->setMaxUrls(5000);
$sitemap->setBuffer(1000);
foreach ($urls as $url) {
$sitemap->addUrl($url);
}
$fileNames = $sitemap->finish();
foreach ($items as $item) {
$sitemap->addUrl($item->link, function($url) use($item){
$url->addImage($item->image, "Caption", "Title");
});
}