By default WordPress orders posts in a descending chronological order i.e from newest to oldest. This is okay if at all one wants their website visitors to see posts in that order. However, in some instances one might want to alter the default WordPress order and instead display posts in alphabetical order.
The following code can be used to alphabetize posts (Display posts in alphabetical order).
<?php $posts = query_posts($query_string . '&orderby=title&order=asc&posts_per_page=10'); //Begining/Start of WordPress loop if(have_posts()) : while(have_posts()) : the_post(); ?> <h3><?php the_title(); ?></h3> <?php the_content(); ?> <?php endwhile; endif; ?>
The above code will select 10 posts per page and display them in ascending alphabetical order (i.e. A – Z) using there titles as defined by paramenters in the string ‘&orderby=title&order=asc&posts_per_page=10′.
If you already have a template that displays the posts in a descending chronological order just simply add the the following line just before the WordPress loop is started.
$posts = query_posts($query_string . ‘&orderby=title&order=asc&posts_per_page=10′);
- Previous Post: Directories For Plugins In WordPress
- Next Post: Changing Feed Cache Lifetime In WordPress