Title: Sorting Results
Last modified: August 19, 2016

---

# Sorting Results

 *  [westondeboer](https://wordpress.org/support/users/poil11/)
 * (@poil11)
 * [17 years ago](https://wordpress.org/support/topic/sorting-results/)
 * The below code is for sorting of posts within a category and what not. You call
   it by using `?sort=name&dir=ASC` at the end of a category example: `http://yourwordpress.
   com/videos/?sort=name&dir=ASC`
 *     ```
       <?php $sortby = $_GET['sort']; ?>
       <?php $dir = $_GET['dir']; ?>
       <?php
       $wp_query->query('cat=7&showposts=5&order='.$dir.'&orderby='.$sortby );
       ?>
       <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
       <?php the_title(); ?>
       <?php endwhile; ?>
       ```
   
 * You can see the things that you can order by at [ ttp://codex.wordpress.org/Template_Tags/get_posts](http://codex.wordpress.org/Template_Tags/get_posts)
   under the $orderby section.

The topic ‘Sorting Results’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [westondeboer](https://wordpress.org/support/users/poil11/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/sorting-results/)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
