Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array

Here’s the code that finally worked for me: <?php global $events_meta_termine; $today = getdate(); $my_query = new WP_Query(‘post_type=events&posts_per_page=-1&monthnum=’.$today[“mon”]); $events=array(); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; $meta = get_post_meta(get_the_ID(), $events_meta_termine->get_the_id(), TRUE); foreach ($meta[‘termin_group’] as $termin) { $event=array(); $event[‘title’]=get_the_title(); $event[‘date’]=$termin[‘termin_date’]; $event[‘time’]=$termin[‘termin_time’]; $event[‘location’]=$termin[‘termin_location’]; $events[]=$event; } endwhile; wp_reset_query(); $i=0; usort($events, “cmp”); function cmp($a, $b){ return strcmp($a[‘date’],$b[‘date’]); } ?> … Read more

Display upcoming events in the next 30 days by querying posts with timestamp in custom meta

I recently did exactly the same, you’ll have to use custom query: $date = time()-86400; /* today */ $querystr = ” SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->posts.post_status=”publish” AND $wpdb->postmeta.meta_key = ‘event_date’ AND $wpdb->postmeta.meta_value > ” . $date . ” ORDER BY $wpdb->postmeta.meta_value ASC “; $pageposts = $wpdb->get_results($querystr, OBJECT); foreach ($pageposts … Read more