I’ve created a custom post type which now has around 100 posts in it. I simply want to display these in alphabetical order by the post title rather than the default which seems to be most recent first. I’ve tried various plugins and other solutions, but most only allow manual sorting (too many posts for that to work), I’m told that the code below should work but it seems to have no effect at all.

Any help appreciated.

<?php 
    $args = array( 'post_type' => 'tenant', 'posts_per_page', 'orderby=title&order=ASC' => 5 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
?>

2 s
2

try this:

<?php 
$args = array( 'post_type' => 'tenant', 'posts_per_page'=>5, 'orderby'=>'title','order'=>'ASC');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>

You will find more info o custom queries here:
http://codex.wordpress.org/Class_Reference/WP_Query

Leave a Reply

Your email address will not be published. Required fields are marked *