Title: Query Problem
Last modified: August 20, 2016

---

# Query Problem

 *  [3Plumes](https://wordpress.org/support/users/3plumes/)
 * (@3plumes)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/query-problem/)
 * All,
 * I’m running a query to return a list of child pages, the related excerpt and 
   featured image thumbnail. The result looks like the following:
 * [Preview](http://dl.dropbox.com/u/4898592/CPP_Profiles.png)
 * As you can see, the list returned isn’t sorted alphabetically, while the side
   bar is. My code is as follows:
 * +++++++++++++++++++++++++++++++
 *     ```
       <h2><?php the_title(); ?></h2>
           <?php $this_page_id=$wp_query->post->ID; ?>
   
       	<?php query_posts(array('order' => 'ASC','showposts' => 20, 'post_parent' => $this_page_id, 'post_type' => 'page')); while (have_posts()) { the_post(); ?>
       		<!--begin profile-->
                            <div class="postprofile">
                               <div class="postprofile_photo">
                                   <?php if ( has_post_thumbnail() ) {
       the_post_thumbnail();
       } else { ?>
       <img src="<?php bloginfo('template_directory'); ?>/imgs/default_thumbnail.gif" alt="No photo available" title="No photo available" />
       <?php } ?>
                               </div>
                               <div class="postprofile_text">
                                   <h4><?php the_title(); ?></h4>
                                   <?php the_excerpt(); ?>
               <p><a href="<?php echo get_permalink(); ?>" title="View profile">View profile</a></p>
                               </div>
                               <div class="rien"></div>
                            </div>
                            <!--end profile-->
   
       	 <?php } ?>
       ```
   
 * +++++++++++++++++++++++++++++++
 * How can I modify the code to have the list display alphabetically by title?
 * Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [defade](https://wordpress.org/support/users/defade/)
 * (@defade)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/query-problem/#post-2135174)
 * i think this may be what you are looking for:
 * [http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters)
 *  Thread Starter [3Plumes](https://wordpress.org/support/users/3plumes/)
 * (@3plumes)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/query-problem/#post-2135176)
 * Defade,
 * That cleared things up a bit. Thanks! I changed **‘order’ => ‘ASC’** to **‘order’
   => ‘title’** and now I get the following: [Preview](http://dl.dropbox.com/u/4898592/CPP_Profiles2.png)
 * As you will notice, they’re all sorted by title, except one (which has the same
   format of a name as the others).
 * Any ideas why this would be happening?
 *  Thread Starter [3Plumes](https://wordpress.org/support/users/3plumes/)
 * (@3plumes)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/query-problem/#post-2135177)
 * Not sure what caused it. I deleted the page, and re-created it, and now all works
   well. Thanks again
 *  [defade](https://wordpress.org/support/users/defade/)
 * (@defade)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/query-problem/#post-2135180)
 * i’m no expert, and it sounds like you got it sorted…
 * from your reply i’d say did you change ‘order’ to ‘orderby’
 * it actually looks like you need BOTH commands:
 * order – chooses the direction of the order
    orderby – chooses what they are sorted
   by
 * so you need:
 * `'orderby' => 'title', 'order' => 'DESC'`
 *  Thread Starter [3Plumes](https://wordpress.org/support/users/3plumes/)
 * (@3plumes)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/query-problem/#post-2135294)
 * Good point. I added:
 * `'orderby' => 'title', 'order' => 'ASC'`
 * Works like a charm. Thanks for the heads up on that.
 * Cheers

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Query Problem’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [3Plumes](https://wordpress.org/support/users/3plumes/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/query-problem/#post-2135294)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
