Wordpress Sitemap without plugin

For all of you who've got a Wordpress blog, and if you ever wondered if you could have a site map of all of your posts without plugin.

This is a handy script that does it.
I prefer not to install plugins if I can manage things in a lighter way, so I'm less updates dependent. Because the thing about using Wordpress is that you should update the Wordpress core and plugins every now and then (too often, to me)

This morning I've tested it on my Wordpress web site, and it works like a charm, here is how to do it:


  • Open your template folder
  • Open the page.php and save it as sitemap.php
  • Replace the Replace <?php the_content(); ?> line with the code you see down here:

Copy this code inside the sitemap.php file, replace the <?php the_content(); ?> withthe following code snippet:

<h3>Pages</h3>
<ul><?php wp_list_pages("title_li=" ); ?></ul>
<h3>Feeds</h3>
<ul>
<li><a title="Full content" href="feed:<?php bloginfo('rss2_url'); ?>">Main RSS</a></li>
<li><a title="Comment Feed" href="feed:<?php bloginfo('comments_rss2_url'); ?>">Comment Feed</a></li>
</ul>
<h3>Categories</h3>
<ul><?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0&feed=RSS'); ?></ul>
<h3>All Blog Posts:</h3>
<ul><?php $archive_query = new WP_Query('showposts=1000&cat=-8');
while ($archive_query->have_posts()) : $archive_query->the_post(); ?>
<li>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
(<?php comments_number('0', '1', '%'); ?>)
</li>
<?php endwhile; ?>
</ul>
<h3>Archives</h3>
<ul><?php wp_get_archives('type=monthly&show_post_count=true'); ?></ul>


  • In Wp-admin dashboard add a new page named: sitemap
  • In the Page Attributes box, choose sitemap  template and then publish this page. That's it!

Comments

Popular posts from this blog

Repair Dolce Gusto Circolo Leaking Problem

Root Nook Simple Touch with updated NookManager

How to Change the Gear Shift Knob of the Peugeot 306