1. Go to this page and download the library: Download aalfiann/sitemap-manager 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/ */
aalfiann / sitemap-manager example snippets
use \SitemapManager\SitemapIndex;
$sm = new SitemapIndex;
// Create blank custom sitemap index
$sm->path = 'sitemap-index.xml';
$sm->create();
// Set the first sitemap file
$sm->path = 'sitemap-index.xml';
// Set the last sitemap file (will increment automatically)
$sm->setLastFile();
// Check the url in all sitemap files
$url = 'http://yourdomain.com/sitemap-test.xml';
if(!$sm->find($url)){
$sm->addBlock($url)
->addLastMod(date('Y-m-d'))
->save();
}
$sm->path = 'sitemap-index.xml';
for ($i=1;$i<10;$i++){
$sm->addBlock('http://yourdomain.com/sitemap-test-'.$i.'.xml')
->addLastMod(date('Y-m-d'))
->enqueue();
}
$sm->save();
$url = 'http://yourdomain.com/sitemap-test-5.xml';
// Set the default path sitemap ( url located
$path = $sm->find($url,false);
if(!empty($path)){
$sm->path = $path;
$sm->setBlock($url)
->unsetLastMod()
->update();
}
$url = 'http://yourdomain.com/sitemap-test-4.xml';
// Set the path sitemap
$sm->path = 'sitemap-index.xml';
$sm->setBlock($url)
->unsetLastMod()
->update();
// Generate All sitemap index into file sitemap.xml
// Note: You need a cronjob to make this refreshed automatically
$sm->generate('https://yourdomain.com');
// Generate All sitemap
use \SitemapManager\Sitemap;
$sm = new Sitemap;
// Create blank custom sitemap urlset
$sm->path = 'sitemap-post.xml';
$sm->create();
// Set the first sitemap file
$sm->path = 'sitemap-post.xml';
// Set the last sitemap file (will increment automatically)
$sm->setLastFile();
// Check the url in all sitemap files
$url = 'http://yourdomain.com/test-suka-suka-aja-13';
if(!$sm->find($url)){
$sm->addBlock($url)
->addChangeFreq('monthly')
->addLastMod(date('Y-m-d'))
->addPriority(0.9)
->save();
}