- This topic has 0 replies, 1 voice, and was last updated 3 years, 5 months ago by
nicos.
Viewing 0 reply threads
-
AuthorPosts
-
-
September 10, 2018 at 4:52 am #9213
nicosParticipantHello,
I try to sort events custom post type by start timestamp, but it doesn’t workfunction get_events($event_types=null, $periode=null, $posts_per_page=-1) { $type_args = array(); if($event_types) { $type_args = array( 'key' => 'event_type', 'compare' => 'IN', 'value' => $event_types, ); } $past_args = array( 'key' => 'event_fin_timestamp', 'compare' => '<', 'value' => strtotime(date("Y-m-d")), ); $present_args = array( 'relation' => 'AND', array( 'key' => 'event_debut_timestamp', 'compare' => '<=', 'value' => strtotime(date("Y-m-d")), ), array( 'key' => 'event_fin_timestamp', 'compare' => '>=', 'value' => strtotime(date("Y-m-d")), ), ); $future_args = array( 'key' => 'event_debut_timestamp', 'compare' => '>', 'value' => strtotime(date("Y-m-d")), ); $periode_args = array(); if($periode) { if($periode == 'past') $periode_args = $past_args; if($periode == 'present') $periode_args = $present_args; if($periode == 'future') $periode_args = $future_args; } $events_query = new WP_query( array( 'post_type' => 'event', 'posts_per_page' => $posts_per_page, 'order_by' => 'meta_value', 'meta_key' => 'event_debut_timestamp', 'order' => 'ASC', 'meta_query' => array( $type_args, $periode_args ) ) ); return $events_query->posts; }Anyone could help me, or send me a link about this subject ?
Thank you, and sorry for my poor english :/
-
-
AuthorPosts
Viewing 0 reply threads
- You must be logged in to reply to this topic.