Title: sector0's Replies | WordPress.org

---

# sector0

  [  ](https://wordpress.org/support/users/sector0/)

 *   [Profile](https://wordpress.org/support/users/sector0/)
 *   [Topics Started](https://wordpress.org/support/users/sector0/topics/)
 *   [Replies Created](https://wordpress.org/support/users/sector0/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/sector0/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/sector0/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/sector0/engagements/)
 *   [Favorites](https://wordpress.org/support/users/sector0/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Let user choose sort order](https://wordpress.org/support/topic/let-user-choose-sort-order/)
 *  [sector0](https://wordpress.org/support/users/sector0/)
 * (@sector0)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/let-user-choose-sort-order/#post-544666)
 * I did some digging and found the answer on the Query Posts page, here:
    [http://codex.wordpress.org/Template_Tags/query_posts](http://codex.wordpress.org/Template_Tags/query_posts)
 * By default, you can set sortorder to author, date, category, or title. There 
   should be an array somewhere in the WP code that defines acceptible sort orders.
   If you can find that array, you should be able to add more (e.g. the modify date).
 * Here is an explanation from an older version. None of the instructions seem to
   work, but the concepts might still be true.
    [http://wiki.wordpress.org/?pagename=HowToChangeSortOrder](http://wiki.wordpress.org/?pagename=HowToChangeSortOrder)
 * I put together a proof-of-concept template. It uses a form to pass the sorting
   details. Here is the relevant code:
 *     ```
       <form method="get" name="testForm">
       	<input type="hidden" name="order" />
       	<ul>
       		<li><a onClick="testForm.order.value='ASC';testForm.submit();">Ascending</a></li>
       		<li><a onClick="testForm.order.value='DESC';testForm.submit();">Descending</a></li>
       	</ul>
       </form>
       <?php
       	if(isset($_GET['orderby']))
       		$sortProperty = $_GET['orderby'];
       	else
       		$sortProperty = 'date';
   
       	if(isset($_GET['order']))
       		$sortDirection = $_GET['order'];
       	else
       		$sortDirection = 'DESC';
   
       	$posts = query_posts($query_string . "&orderby=$sortProperty&order=$sortDirection&posts_per_page=-1&category_name=reviews");
       ?>
       ```
   

Viewing 1 replies (of 1 total)