views:

116

answers:

1

Hi,

The Problem: I would like to sort my posts based on custom fields, when the user clicks on a link. I don't know if there is a parameter that can be passed via url to reorder posts.

Comparison: I would like it to work similar to how you can sort songs in iTunes. The user simply clicks the "Artist" button and the songs are reorder alphabetically by artist's name.

Example: The custom field could be the location where I was when I wrote the post. "Location = home" or "Location = office" etc. When the user click a links the page is reload with the posts reordered. Posts from home before ones from the office.

Thanks for the help.

A: 

query_posts('&meta_key=location&orderby=meta_value');

This will sort by location, and exclude all posts that don't have a location field.

Chacha102