I maintain a site with pages on individuals, locations,and news categories. I want to display the names in alphabetical order, by last name, and I have added a custom field,lastname, in order to do so.
I get partway there by inserting
<?php $posts = query_posts( $query_string . '&orderby=lastname&order=asc'); ?>
in archive.php just before The Loop. Two problems remain:
- All categories are sorted. I only want the Names in alphabetical order. I want the other categories in default latest-first date order.
- If I use order=asc, the names sort in descending order (z-a) within the date posted. October 2011 Z through A; then October 2012 Z through A; etc. If I use order=desc, they list only by date, with no sorting on name at all.
If you want to see it in action, the site is http://fallenleaves.org/
How do I get the Names category to ignore the date of posting entirely, and sort only by last name, a-z, while Locations and News sort by date posted, descending?