Sorting Results
-
The below code is for sorting of posts within a category and what not. You call it by using
?sort=name&dir=ASCat 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.ww.wp.xz.cn/Template_Tags/get_posts under the $orderby section.
The topic ‘Sorting Results’ is closed to new replies.