• I have a page that lists events sorted by a custom field called “Date”. I sort them in my SELECT statement. The problem is that some events occur on the same day, in which case I need to sort them by an additional custom field called “Time Start”. But I can’t see a way to accomplish this in the SELECT statement, especially since not all events have a “Time Start” value. I was thinking that I ought to just sort the results, maybe by creating a timestamp by combining the two fields for each post. But, as far as I know, this would have to be done to the results of the query rather than in the SELECT statement. Is there a way to sort the results (the OBJECT) this way?

Viewing 1 replies (of 1 total)
  • Thread Starter fgshepard

    (@fgshepard)

    UPDATE: Another question is this: can I retrieve to custom fields in the same SELECT statement? So i’d have wpostmeta.meta_key = “Date” as well as wpostmeta.meta_key = “Time Start” in my SELECT statement? If so, how do I distinguish the values in the ORDER BY statement? I want to order by year, month, day, hour (in that order), but the date and time info are in separate custom fields.

Viewing 1 replies (of 1 total)
  • The topic ‘sorting by 2 custom fields’ is closed to new replies.