This is a super simple and quick guide to help you create a WordPress Sitemap without using a plugin. No plugin required at all!
Updates for 2021
As this is one of the most popular tuts on my blog (thanks for visiting), I have updated this WordPress Sitemap without a plugin for 2021. This includes more annotation, custom post types, and an improved WP Query loop.
1. Custom Post Types: I’ve included CPTs on this sitemap page, so all you need to do is replace the cpt-slug in the WP Query with your CPTs slug.
2. Improved WP Query Loop: I’ve added a few extra options on all the WP Query loops below. That includes ordering by alphabetically by title.
3. More Annotation: I’ve added some more annotation to make it easier for you to understand and customise the loop below.
Why would you want to not use any third-party plugins to create a sitemap?
It’s really simple. All WordPress websites created by the average user should look to maintain a fully functioning site with somewhere around ~10 front-facing plugins. For reasons such as speed, flexibility, security and compatibility. Some plugins which are not secure can leave your website vulnerable, they can also be incompatible with other plugins resulting in your website not loading and producing errors, and the third reason because of speed, some plugins are bulky and overloaded with code.
Oh, and most important of all it is actually super simple to do if you follow these easy instructions below. So, pull up your sleeves you’ve got to get stuck in and learn how to create a WordPress Sitemap without using a plugin
Create WordPress Sitemap without Plugin
Before you start – You need to have administrative access to your WordPress site and FTP access. You should also always take a full database and theme file backup before making any changes.
1. Go to your theme folder
2. Create and name a file page-sitemap.php
3. Paste the code below into the page-sitemap.php file
4. Create a new page in the backend of your WordPress install. Select the page template “Sitemap”
5. Now tweak to fit your site
WordPress Sitemap Page Code
Below is the WordPress sitemap file. This supports Posts, Pages, Custom Post Types and WooCommerce Products. If you don’t want or need Custom Post Types or WooCommerce products support then just delete those loop at the bottom (I’ve annotated each section so should be easy to find).
Dougie,
This was so clean and clear – and therefore, easy. Oh that all tutorials could be done this way.
Well done.