I wanted a simple hands on way to make a site map. On an SEO point of view, a site map makes a website easier to read for search engines. To me, an even more important use for it is that it is a simple interface for a human to see everything on the website. No images, just a list. Since all of the posts in my blog fall into categories, I simply listed out the posts by category, placing the categories in an order I liked. If you have created a taxonomy in a similar way, this method may be useful for you. Here’s how to do it. (Note: You’ll need shell access)
The first thing I did was create a WordPress Page for it, and call it “Sitemap”. You can find this function in the dashboard under “Pages>>Add New”. Then click “All Pages” and move your mouse cursor over the “Sitemap” one you just made. You’ll see it points to a link. This gives you the ID of your page.
http://whichlight.com/wp-admin/post.php?post=1266&action=edit
In my case it’s 1266. Now ssh onto your server and navigate to the folder with all of your blog templates. Its under
wp-content/themes/<your-theme>/
Here copy your Page template and call it page-ID.php. In my case it was “page-1266.php”. You can really begin with any template, or you don’t have to. I just find it easier to start with something.
In my template, my structure is as follows:
- Header
- Sitemap
- Enormous Tag Cloud (optional)
- Sidebar
- Footer
For the “Sitemap”, as the name reveals, contains all the meat for this page. For each category, I write the following
<h2> Category Name </h2>
<ul>
<?php
global $post;
$args = array(‘numberposts’ => -1, ‘category’ => category_ID );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
I’ve bolded the things you fill in for each category. I just simply copy and pasted this snippet for each category. Here is an example for my blog posts:
<h2> Blog </h2>
<ul>
<?php
global $post;
$args = array(‘numberposts’ => -1, ‘category’ => 284 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
The Tag Cloud is just something I like.
<h2>Super Tag Cloud </h2>
<div id=’tagcloud’><?php wp_tag_cloud(array(‘number’ => 0) ); ?> </div>
And that’s it!
