[resolved] Sorting Posts in Alphabetical Order (3 posts)

  1. Matt Hancock
    Posted 6 years ago #

    So I have this query which lists all the posts by category on a sidebar. I want to expand it slightly so that it lists the posts in alphabetical order.

    Code is as follows:

    <ul class="sidebar">
    <?php $recent = new WP_Query("cat=3&showposts=10"); while($recent->have_posts()) : $recent->the_post();?>
    <li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>

    Any help would be appreciated.

  2. esmi
    Forum Moderator
    Posted 6 years ago #


    <?php $recent = new WP_Query("cat=3&posts_per_page=10&orderby=title");

  3. Matt Hancock
    Posted 6 years ago #

    Just had to modify it slightly to get the order correct:

    <?php $recent = new WP_Query("cat=3&posts_per_page=20&orderby=title&order=asc");

    Cheers :)

Topic Closed

This topic has been closed to new replies.

About this Topic