[wp-hackers] WP_Query to sort by Custom Fields
wordpress at danielbachhuber.com
Mon May 16 13:26:49 UTC 2011
A better solution to your problem would be to store the event day and month together as a UNIX timestamp. It's a simpler query and will be more flexible in the long run.
On May 16, 2011, at 9:17 AM, John Blackbourn <johnbillion+wp at gmail.com> wrote:
> On 16 May 2011 14:15, Christopher Ross <cross at thisismyurl.com> wrote:
>> Is it possible to sort a WP_Query but custom field results (ideally multiple)?
>> I have a query that requires me to fetch a series of events, the site developer used a custom post type and inserted the day and month as custom fields, so now what I need to do is fetch the most recent 15 events. By default, it shows me the 15 that appeared in the database last but what I need is the month-day combo instead.
>> One way to do it obviously would be to fetch all events and then sort but there are thousands in the system. Even if I limited to just this month and last, there are still a lot. So, what's the best way to fetch and sort posts based on multiple custom fields?
> Yep, see http://scribu.net/wordpress/advanced-metadata-queries.html
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers