Created
July 30, 2018 13:31
-
-
Save dnavarrojr/975f9227f2e40e9c978fe5538235b6d8 to your computer and use it in GitHub Desktop.
WordPress Sort CPT by Date and Time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$args = array( | |
'post_type' => 'eventsapi', | |
'numberposts' => -1, | |
'meta_query' => array( | |
'event_date' => array( 'key' => 'event_date', 'value' => $date, 'compare' => '=' ), | |
'event_time' => array( | |
'relation' => 'OR', | |
array( 'key' => 'event_start', 'compare' => 'EXISTS' ), | |
array( 'key' => 'event_start', 'compare' => 'NOT EXISTS' ), | |
), | |
), | |
'orderby' => 'event_date event_time', | |
'order' => 'ASC', | |
); | |
$eventsapi = get_posts( $args ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment