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:
- is fun
- is more flexible
- gives you more control over its content
- displays the list the way you choose
- 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:
- download and install the PHP Exec plugin (or similar)
- download and install the Sobek’s Post in Category plugin
- 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:
- Tutorial: Automatic Site Map for WordPress by Jim Westergren
- The Art of a Good Site Map and Help Visitors Navigate Your Site: Make a Site Index by Lorelle
Other resources
If you are looking for other resources concerning XML and HTML Sitemaps, feel free to visit:
- Google (XML) Sitemaps Generator for WordPress by arne
- Sitemap Generator by Dagon Design
- the wp_get_archives() tag
Tags: category, index, plugin, posts, site, sitemap, tutorial



4:04 pm
Sobek`s Post in Category plugin : Sobek`s Wordpress Plugins
[...] You may also want to read the tutorial I wrote for the [...]
4:12 am
Daniel
I couldn’t understand some parts of this article Handmade Wordpress sitemap - a tutorial, but I guess I just need to check some more resources regarding this, because it sounds interesting.
1:54 pm
Speeddating
You have done a great job on this blog, providing excellent information
4:53 pm
simple67
[...] here No Comments so far Leave a comment RSS feed for comments on this post. TrackBack URI [...]
1:20 pm
Łukasz Sobek
@Daniel
I’ll go over it in a few days and try to make it simpler :) (maybe I’ll just cut out some of the advanced things and post them in a follow-up tutorial)
11:00 am
lance
It sounds interesting! I never thought that we can make hand made sitemap on WP. I’ll try this…thanks for sharing!
9:36 pm
booksXYZ
The problem I have with this is the problem I have with so much of WordPress… nobody shows me a blog with and without the Plug-in, with just a few sentences explaining what was done with the Plug-In, that couldn’t be done without it.
That would be such a help to those of us who are trying to solve problems with our blogs. Thanks–
4:34 am
Aaron
Any way of adding a date field to the output so that you can see a list like
* Post title - date
* Post title - date
* Post title - date
What follows the title shouldn’t be part of the link.
1:33 pm
Bas
I have a problem with the PHP code in the page-code editor.
When I paste the code stated above in my code editor, and press ’save’, the code will disappear! The only code that will be saved is:
Main category
Subcategory
The PHP between de simply disappears!
Any solution for this problem?
12:17 am
Łukasz Sobek
@Aaron: Please re-read the feature list of the plugin.
@Bas: switch to code view for editing the tags. I am still fighting to understand regular expressions which would allow to implement the code more easily.
12:42 am
Aaron
Regarding #6, I meant to post the question in your http://wordpress.sobek.pl/sobeks-post-in-category-plugin/ post.
7:02 pm
sitemap
Sitemap Creator
7:32 pm
majestic
excellent,,,thanks