Support

Account

Home Forums General Issues meta_query orderby overwritten by publish date Reply To: meta_query orderby overwritten by publish date

  • Hi Andrea,

    So, the problem I had was that I made the mistake of thinking that my date and time picker custom field (showing time only) was linked/relative to the date and time picker custom field (displaying both date and time). They’re not linked, rather the time only picker value sets the time relative to the publish date of the post!

    So, here’s how my fields were set up:

    Date of event: date and time picker field (field name: day)

    Event time start: date and time picker field — time display only (field name: schedule_time_start)

    Event time finish: date and time picker field — time display only (field name: schedule_time_finish)

    So, for example, a post using these fields would be entered as:

    Date of event: 8/6/2016 12:00am
    Event time start: 9:00am
    Event time finish: 10:00am

    If I published this post on say, April 1, 2016 the ‘schedule_time_start’ was stored as 1459501200 which is the equivalent of April 1, 2016 9:00am GMT!

    That was the problem. What I should have done was ditched the event date field and just used the event time start & finish fields as date and time pickers.

    I had to debug this by querying the values that were being store in the wp_postmeta table in the database. This showed that the time values were set relative to the publish date.

    I hope this helps you.