Skip to content

Instantly share code, notes, and snippets.

@blha303
Created July 24, 2019 01:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blha303/6d1537532d183797597f81f6a412b32a to your computer and use it in GitHub Desktop.
Save blha303/6d1537532d183797597f81f6a412b32a to your computer and use it in GitHub Desktop.
Generates a sitemap.xml from Wordpress
<?php
include( './wp-load.php' );
header("Content-Type: application/xml");
?>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <?php
foreach(get_pages() as $page) { ?>
<url>
<loc><?php echo get_page_link( $page->ID ); ?></loc>
<lastmod><?php echo date("Y-m-d", strtotime($page->post_modified)); ?></lastmod>
</url>
<?php } ?>
</urlset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment