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.
[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:
<?php sobeks_posts_in_category(3); ?>
<h2>Two subcategories at once</h2>
<?php sobeks_posts_in_category(4,33); ?>
<?php sobeks_posts_in_category(5); ?>
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>
<?php sobeks_posts_in_category(7); ?>
<?php sobeks_posts_in_category(8); ?>
<?php sobeks_posts_in_category(9,10,11,12,13); ?>
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
If you are looking for other resources concerning XML and HTML Sitemaps, feel free to visit: