Now Reading
How create Sitemap For wordpress Without Plugins

How create Sitemap For wordpress Without Plugins

by AdminAugust 25, 2016

As we know that plugin is a considerable feature in WordPress, it Ads new functionality to your WordPress site. But use excessive of plugins in WordPress it might have become headache for you. It can slow your site. HTML sitemap design for users, where the user can easily view all links, pages, and category of your site.

Sitemaps are an essential part of SEO, they allow the search engine bots to access all your posts, pages and other post types from one location.

Easy WordPress Sitemap Page without Plugins Guide

Before you start – You need to have administrative access to your WordPress site and FTP access.

Step 1: Go to your theme folder.

Step 2: Create and name a file page-sitemap.php.

Step 3: Paste the code below into the page-sitemap.php file.

Step 4: Create a new page in the backend of your WordPress install. Select the page template “Sitemap”.

Step 5: Now tweak to fit your site. Let me know how you got on by leaving a comment below.

Sitemap Page Code

I’ve added spaces between each section to make it easier to get your head round when first using it. I know HTML and PHP can be daunting for first-time users. Trust me it gets easier.

Template Name: Sitemap
get_header(); ?>

Next we need some javascript which handles the toggles :

<div id=”primary” class=”site-primary-wide content-area”>
<main id=”main” class=”main” role=”main”><div class=”sitemap-module module”><h1>Sitemap</h1>

<!– This section shows a list of pages –>

<h2 id=”pages”>Pages</h2>
// Add pages you’d like to exclude in the exclude here
‘exclude’ => ”,
‘title_li’ => ”,

<!– This section shows a list of posts by category –>

<h2 id=”posts”>Posts</h2>
// Add categories you’d like to exclude in the exclude here
$cats = get_categories(‘exclude=’);
foreach ($cats as $cat) {
echo “<li><h3>”.$cat->cat_name.”</h3>”;
echo “<ul>”;
while(have_posts()) {
$category = get_the_category();
// Only display a post link once, even if it’s in multiple categories
if ($category[0]->cat_ID == $cat->cat_ID) {
echo ‘<li><a href=”‘.get_permalink().'”>’.get_the_title().'</a></li>’;
echo “</ul>”;
echo “</li>”;

<!– This section shows a list of custom post types (so acts likes a catch-all) –>

foreach( get_post_types( array(‘public’ => true) ) as $post_type ) {
if ( in_array( $post_type, array(‘post’,’page’,’attachment’) ) )
$pt = get_post_type_object( $post_type );
echo ‘<h2>’.$pt->labels->name.'</h2>’;
echo ‘<ul>’;
while( have_posts() ) {
echo ‘<li><a href=”‘.get_permalink().'”>’.get_the_title().'</a></li>’;
echo ‘</ul>’;
</div></main><!– #main –>
</div><!– #primary –><?php get_footer(); ?>

Don’t forget to let me know how you get on using this by sticking a comment in below. As I’d like to know whether it’s worth me putting more stuff like this together for beginners, and what sort of things are useful.

Please wait...
About The Author

Leave a Response