How to add custom urls programmatically
-
Hello
I created custom urls that are not included in sitemap.
How can I add urls programmatically?I tried
private function addUrlsToSitemap($linkUrls){ require_once('wp-content/plugins/google-sitemap-generator/sitemap-loader.php'); require_once('wp-content/plugins/google-sitemap-generator/sitemap.php'); $googleSitemapGeneratorLoader = new GoogleSitemapGeneratorLoader(); $googleSitemapGeneratorLoader->LoadPlugin(); if(class_exists('GoogleSitemapGeneratorPage')){ $priority = '0.5'; $changeFreq = 'weekly'; $lastMod = time(); foreach ($linkUrls as $key=>$linkUrl) { $pages[] = new GoogleSitemapGeneratorPage($loc, $priority, $changeFreq, $lastMod, null); } $sg = GoogleSitemapGenerator::GetInstance(); $sg->SetPages($pages); $sg->SavePages(); return; } }
But urls aren’t saved.
I’m afraid I am missing one last step.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to add custom urls programmatically’ is closed to new replies.