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.


Read more here: Incorrect ordering of custom post type based on time


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: