Monthly Archives: October 2012

Sort Posts on Multiple Custom Fields

This code is in response to a request to sort posts on 6 Custom Fields, but the approach should apply to any number of Custom Fields.

Adding 6 joins to the query would result in significant overhead to the query, so an alternate method was developed which adds no additional joins or queries.

The meta_keys are named in an array. The first key is used to select posts, so all posts must have at least this Custom Field.

Continue reading