order by multiple dates on custom post type “earthxfilm_events” with post_meta key “event_date_time”

How can I order my custom posts with multiple metadata dates? dates are UNIX timestamp

function get_all_events(){
$curPage = $_GET[‘displayPage’];
$categoryToDisplay = $_GET[‘category’];
$order = $_GET[‘order’];
$orderBy = $_GET[‘orderBy’];
$resultsPerPage = $_GET[‘resultsPerPage’];
$taxQuery = $categoryQuery;
if(!empty($categoryToDisplay)){
$categoryQuery = array(
array(
‘taxonomy’ => ‘event-category’,
‘field’ => ‘slug’,
‘terms’ => $categoryToDisplay,
));
}else{
$categoryQuery = ”;
}

$args = array(
‘post_status’ => ‘publish’,
‘orderby’ => $orderBy ,
‘order’ => $order,
‘post_type’ => ‘earthxfilm_events’,
‘posts_per_page’ => $resultsPerPage,
‘paged’=> $curPage,
‘tax_query’=>$categoryQuery,
‘meta_key’=> ‘event_date_time’
);
$loop = new WP_Query( $args );
$max_pages = $loop->max_num_pages;
$all_events = $loop->posts;
foreach($all_events as $event){
$pID =$event->ID;
$event_image_url = get_the_post_thumbnail_url($pID);
$event_dates = rwmb_meta( ‘event_date_time’, $args, $pID );
$event_location = rwmb_meta( ‘event_location’, $args, $pID );
$event_run_time = rwmb_meta( ‘event_run_time’, $args, $pID );
$event_custom_link = rwmb_meta( ‘event_custom_link’, $args, $pID );
$event_description = rwmb_meta( ‘event_description’, $args, $pID );
$event_link = get_the_permalink($pID);
echo ‘<div class=”event-square”>’;
echo “<a href=’$event_link’ class=’event-pic’ style=’background:url(“.$event_image_url.”);background-size:100%;’>”;
echo ‘<span class=”transparent-bg flex justify-align-center align-content wrap”>’;
echo ‘<h2 class=”event-name”>’.$event->post_title.'</h1>’ ;

echo ‘<p>’;
foreach($event_dates as $event_date){
// echo $event_date;
$formattedDayMonth = date(‘F j, h:i A’,$event_date);
echo $formattedDayMonth . ‘ | ‘ ;
}
echo $event_run_time . ‘</p>’;
echo “<p>$event_location[0]</p>”;
echo ‘</span>’;

echo ‘</a>’;
echo ‘<p class=”event-description”>’
. $event_description
. ‘</p>’;
foreach($event_custom_link as $link){
echo “<a target=’_blank’ class=’btn-theme custom-link’ href=’$link[0]’>$link[1]</a>”;
}

echo ‘</div>’;

}
echo ‘</div>’;
$this->get_pagination($max_pages,$curPage);

die();
}

Read more here:: order by multiple dates on custom post type “earthxfilm_events” with post_meta key “event_date_time”

Leave a Reply

Your email address will not be published. Required fields are marked *