sector0
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: Let user choose sort orderI did some digging and found the answer on the Query Posts page, here:
http://codex.wordpress.org/Template_Tags/query_postsBy 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=HowToChangeSortOrderI 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)