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>
<?php wp_get_archives('type=alpha');?>

5 thoughts on “A list of all posts in an alphabetical order

  1. Wow, I’ve been trying to figure out how to do this within my Sitemap. I had no idea it was so simple! This was very helpful. Thanks!

  2. THANK YOU!!!

    I don’t know why I couldn’t find this on the WordPress site. I just spent a ridiculous amount of time, and you rescued me from a meltdown.

  3. Is social media going to kill SEO?

  4. I was using azindex plugin to index my posts in alphabetical order and create a TOC like page, bu suddenly it stopped working, can anyone help me out with anyother method which i can understand, i know nothing about coding

Comments are closed.