ClockWorkBlogger » Page 'Handmade Wordpress sitemap – a tutorial'

Handmade WordPress sitemap – a tutorial

This Tutorial has been updated to reflect the changes in v1.5 of the plugin.

After publishing the Sobek`s Post in Category plugin I thought it a good idea to write a couple of lines about how to create a manual WordPress “Site map” or “Site index” for your WordPress 2.3+ blog.
The terms “sitemap” or “site index” in this tutorial do not refer to a WordPress Google Sitemap, but to a page displaying the contents of your WordPress powered site in HTML.

There are, of course, plugins like the Dagon Design Sitemap Generator, which let you set up a 100% automatic sitemap and are very easy to use, or as Jim Westergren puts it:

[DDSG] is an extensive plugin with a lot of options and is 100% automatic. Just follow the instructions on that site on a new site map page and then in your template footer file and or at some other visible place, make a link pointing to your site map for full visitor and search engine link benefit.

Your own “handmade” Sitemap

Having said the above, I’d like to present a way to create your own handmade sitemap, not because I don’t like automatic ones – in fact I found some of them to be brilliant – but because building your own site index:

  1. is fun
  2. is more flexible
  3. gives you more control over its content
  4. displays the list the way you choose
  5. will make you never want to go back to 100% automatic again

Step 1 – Prepare yourself

Depending on the size of your WordPress powered site, prepare to spend about 20 minutes to set up the first version of your fully handmade site index, also:

  1. download and install the PHP Exec plugin (or similar)
  2. download and install the Sobek’s Post in Category plugin
  3. prepare a list of ID numbers of the categories you would like to include in your sitemap

Let’s move on to step 2

Step 2 – Prepare the page

Enter your WordPress admin panel, go to “write” >> “write page” and in “code view” create a new page called “Sitemap” with the following content:

<h1>Main category</h1>

<div style=”margin-left:30px;”>

<h2>Subcategory</h2>
<ul>
<?php sobeks_posts_in_category(3); ?>
</ul>

<h2>Two subcategories at once</h2>
<ul>
<?php sobeks_posts_in_category(4,33); ?>
</ul>

<h2>Remaining posts</h2>
<ul>
<?php sobeks_posts_in_category(5); ?>
</ul>

</div>

The numbers within the sobeks_posts_in_category() tags are the ID numbers of the categories you prepared earlier. If you put more than one number within the brackets, separate them with commas eg. sobeks_posts_in_category(5,6,7,8,9)

Step 3 – Repeat step 2

Next, do the same for each main category you want to inlude in your site index:

<h1>Other main category</h1>

<div style=”margin-left:30px;”>

<h2>Other subcategory</h2>
<ul>
<?php sobeks_posts_in_category(7); ?>
</ul>

<h2>Other subcategory</h2>
<ul>
<?php sobeks_posts_in_category(8); ?>
</ul>

<h2>Remaining posts</h2>
<ul>
<?php sobeks_posts_in_category(9,10,11,12,13); ?>
</ul>

</div>

Save the page i.e. click “publish” in WordPress

Step 4 – Linking it

Place a link to your newly created page in your header or footer or anywhere you need it.

Step 5 – You’re done

That’s basically it. The plugin has more options, such as sorting by date and displaying the number of coments to a post etc., so, if you are interested, please visit the plugin page.

Other things worth reading

If you want to read some more about HTML site indexes you may want to browse these:

Other resources

If you are looking for other resources concerning XML and HTML Sitemaps, feel free to visit:

19 comments to “Handmade WordPress sitemap – a tutorial”

Like my work?

Amount:
Website(Optional):

Leave a comment