Created
July 24, 2019 01:09
-
-
Save blha303/6d1537532d183797597f81f6a412b32a to your computer and use it in GitHub Desktop.
Generates a sitemap.xml from Wordpress
This file contains hidden or 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
<?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