02 Feb, 2009
A list of all posts in an alphabetical order
Web Development » Snippets, WordPress » A list of all posts in an alphabetical order
It is not uncommon for a WordPress blog to display a list of all posts in an alphabetical order. I was using <?php wp_get_archives('type=postbypost');?> to display all posts by post title but I couldn’t find a way to sort the post titles in an alphabetical order. After looking at the source code (general-templates.php), I noticed that WordPress already has a built-in functionality that does that. All you need to do is replace postbypost with alpha and it will displays all posts in an alphabetical order of the post title. Not sure why it isn’t mentioned in wp get archives Template Tags page.
Usage demo:
in sidebar.php
<div id="archive">
<h2 class="title">Archive</h2>
<div>
<ul>
<?php wp_get_archives('type=alpha');?>
</ul>
</div>
</div>
Other similiar posts that you might be interested in:
- 5 steps to creating a custom Archive page in WordPress
- Display 5 latest posts in each category in WordPress
- Customising category.php in WordPress
- Display 10 recent post titles on homepage
- How to add a breadcrumb to your blog and have it appear on Google’s Search Result Snippet
- WordPress iPhone App – a step by step user guide to using WordPress for iPhone
- 7 Link Challenge for Web Development Blog






