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>
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!
Really helpful, thanks man!! was looking all over the net for this one.
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.
Is social media going to kill SEO?
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