MAMP.ONE

web publishing magazine

WordPress —
Create sitemap.xml without PlugIn

If you want to create a sitemap.xml (for example for Google’s Search Console) with WordPress and do not want to use a plug-in, you can do this with the following PHP code. This must be in the functions.php file of the theme. In this example, all posts and pages are listed in the sitemap file. As soon as a post or a page is created or modified, the sitemap file is rewritten.

If you publish the WordPress blog via MAMP PRO (Remote-Tab), you have to replace the local host with the target host name when outputting the URL (field <loc>). The following example shows this.