How to create a sitemap in WordPress without plugin

mm
How to create a sitemap in WordPress without plugin
4.5 (90%) 4 votes

Sitemaps are important for SEO because they make it easier for Google or search engine to find your site’s pages.  it is a communication tool between your website and search engines. By using this method you can include any custom post types your site may use pretty easily.

Follow these steps to create a sitemap in WordPress without any plugin:

Create a copy of your page.php template and save it as sitemap.php ( this is so it matches your theme & has the correct layout elements, sidebar etc) then at the top paste in:

Next, we need some javascript which handles the toggles:

And this is the code to display your posts and pages on the sitemap:

If you need to add in custom post types, you can add as many as you like individually with the following code, change POSTTYPENAME in two places to the name of required post type:

Finally add this to your style.css to add some styling for the toggling:

The last thing to do is publish the page which will house your Sitemap, visit “Pages” > “Add New”, after naming the page and adding any content to the page body choose “Sitemap” from the template drop-down on the right under “Page Attributes”

 

How to create a sitemap in WordPress without plugin
4.5 (90%) 4 votes

Leave a Comment

Your email address will not be published. Required fields are marked *