WordPress Events manager – wp_query for lastest event
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
global $post; $time = date ('m/d/Y'); // Set up custom query with meta_query to compare event start date with today's date $args = array ( 'post_type' => 'event', // your event post type slug 'post_status' => 'publish', // only show published events 'orderby' => 'meta_value', // order by date 'meta_key' => 'event_start_date', // your ACF Date & Time Picker field 'meta_value' => $time, // Use the current time from above 'meta_compare' => '>=', // Compare today's datetime with our event datetime 'order' => 'ASC', // Show earlier events first 'posts_per_page' => 10, ); // The Query $listings = new WP_Query(); // The Loop $listings->query($args); if($listings->found_posts > 0) { echo '<ul>'; while ($listings->have_posts()) { $listings->the_post(); $id = $post->ID; //echo $id; $newDate = date_i18n(get_option('date_format'), strtotime(get_post_meta($id, 'event_start_date', true))); //$event_data = get_post_meta($id); //print_r($event_data); if(get_post_meta($id, 'event_start_date', true)){ $listItem = '<li>'; $listItem .= '<a href="' . get_permalink() . '">'; $listItem .= get_the_title() . '</a>'; $listItem .= '<br><span> ' . $newDate . '</span></li>'; $listItem .= '</li>'; echo $listItem; } } echo '</ul>'; wp_reset_postdata(); } else { // no posts found echo '<p style="padding:25px;">Aucun événement</p>'; } |
antibioticszob
Special offer for antibiotics: order cheap antibiotics without rx and get discount for all purchased! Two free pills (Viagra or Cialis or Levitra) available with every order. No prescription required, free delivery.