The basics of this should work with about any WordPress theme, but the Twenty Eleven theme is the newest default theme for WordPress. With all the great features it has out of the box, I decided to activate it here. Only a few minor adjustments were made to fulfill what I wanted it to do. The biggest change was making a page that would list all of my tutorials. In the past, I’ve put this list in the sidebar, but have since decided to run the site without a sidebar(at least for now). Here’s how I made the page template.
First up, I copied my archive.php file, and named the copy category-tutorials.php. The first change I made to my new template was place this code at the top.
<?php /* Template Name: Category-Tutorials */ ?>
This code is what will make the new page template show up as a template option, but more on that later.
In Twenty Eleven, the archive.php template has a ‘page header’. I left that. So, from the closing </header> tag all the way down to the closing content div – </div><!– #content –>, is the WordPress loop. I replaced the loop with this:
<ul class="category"> <?php $archive_query = new WP_Query('cat=7&showposts=1000'); 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></li> <?php endwhile; ?> </ul>
You’ll notice in the code, my WP_Query calls for “cat=7″, which is category ID 7(my Tutorials category ID). Then it calls for “showposts=1000″, so that it will list ALL the posts in this category. Of course you would need to replace the 7 with the category ID that you are making this page for.
One other change I made, was in the “page-title” code. I changed the word “Blog Archives” to “Tutorials”. You’ll have to glance over the code to find it. This gives the page a heading…Tutorials.
Save that, and the template is done. Upload to the Twenty Eleven theme folder.
All that’s left at this point is to create your page in the WordPress admin. Go to Pages > Add New, and Create a new page. I named mine Tutorials. On the right side of the screen there is a drop down where you can choose a custom page template. I chose my new template out of the drop-down box, and published.
That’s it! All information was gained from the WordPress Codex plus a couple of Google searches.
You can download a copy of mine here.