0

I have a custom post type as event which accept Custom fields' values as

gp_event_date as ( 2015/02/26)

gp_event_time as (SIMILAR) to 08:00PM - 10:00PM format.

And on the list page, it orders the display of post according to this date and time combination.

But somehow the order is not proper, as it is not identifying the correct time on the same data i guess.

Here is the code used in loop

// Query
                $gp_query_args = array(
                    'post_type'         => 'event',
                   'meta_key'           => 'gp_event_date',
                   'meta_value'     => date('Y/m/d'),


                  'meta_compare'        => '>=',
                    'orderby'           => 'meta_value',
                    'order'             => 'ASC',
                    'posts_per_page'    => -1
                );

Now i can see that there is no comparison of time if there are multiple events on the same day, but in actual, when viewing the output, the page displays list of events ordered by data and time upto some extent, but in some cases that order is not proper.

For example :

event 1: date(y/m/d) 2015/02/06 time: 01:00PM TO 03:00PM
event 2: date(y/m/d) 2015/02/06 time: 11:00AM TO 12:30PM
event 3: date(y/m/d) 2015/02/06 time: 04:00PM TO 06:00PM

So you got what's the issue right?? I'm looking for a way to control more specifically the order of events based on date and time correct combination.

Thanks

1

Instead of event date and event time, make the meta keys start time and end time and save them both as timestamps, then events will order correctly when sorted by start time key only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.