Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h1>Upcoming</h1>
- <?php
- for ($i=0; $i<10; $i++) {
- $thedate = strtotime ( '+'.$i.' day' , strtotime ( $today ) ) ;
- $thedate = date ( 'Y-m-d H:i' , $thedate );
- $thedaytext = strtotime ( '+'.$i.' day' , strtotime ( $todaytext ) ) ;
- $thedaytext = date ( 'l' , $thedaytext );
- $thedatetext = strtotime ( '+'.$i.' day' , strtotime ( $todaydatetext ) ) ;
- $thedatetext = date ( 'F j' , $thedatetext );
- $future = strtotime ( '+24 hours' , strtotime ( $thedate ) ) ;
- $future = date ( 'Y-m-d H:i' , $future );
- $times = array(); // put before the $event_query and seems to work
- $args = array(
- 'post_type' => 'event',
- 'orderby' => 'meta_value',
- 'order' => 'asc',
- 'meta_query' => array(
- 'relation' => 'OR',
- array(
- 'key' => 'opening_time',
- 'value' => array($today,$future),
- 'compare' => 'BETWEEN',
- 'type' => 'DATE'
- ),
- array(
- 'key' => 'artist_talk_time',
- 'value' => array($today,$future),
- 'compare' => 'BETWEEN',
- 'type' => 'DATE'
- ),
- array(
- 'key' => 'closing_time',
- 'value' => array($today,$future),
- 'compare' => 'BETWEEN',
- 'type' => 'DATE'
- ),
- array(
- 'key' => 'special_event_time',
- 'value' => array($today,$future),
- 'compare' => 'BETWEEN',
- 'type' => 'DATE'
- )
- )
- );
- $event_query = new WP_Query( $args );
- if ($event_query->have_posts()) : while ($event_query->have_posts()) : $event_query->the_post();
- $keys = array('opening_time', 'closing_time', 'artist_talk_time', 'special_event_time');
- $custom_field_keys = get_post_custom_keys();
- foreach ($custom_field_keys as $custom_field_key) {
- if (in_array($custom_field_key, $keys)) {
- $custom_field_value = get_post_meta($post->ID, $custom_field_key, true);
- if ($custom_field_value >= $thedate && $custom_field_value <= $future) {
- $counttest++;
- $times[] = array($custom_field_value, $post->ID, $custom_field_key);
- }
- }
- }
- endwhile;
- ?>
- <ul>
- <?php
- if ($counttest >0) {
- ?>
- <li>
- <h1 class="upcoming_date">
- <span class="total">
- <?php
- echo $counttest;
- if ($counttest>=2) {
- echo ' Events ';
- } // end if ($totalevents>=2) function
- if ($counttest<2) {
- echo ' Event ';
- }
- ?>
- </span> <!-- end .total -->
- <span class="day_sidebar">
- <?php
- if ($thedate==$today) {
- echo 'Today';
- }
- if ($thedate>$today) {
- echo $thedaytext;
- }
- ?>
- </span> <!-- end .day -->
- <span class="date_sidebar">
- <?php
- echo $thedatetext;
- ?>
- </span><!-- end .date -->
- </h1>
- </li>
- <?php
- }
- endif;
- $counttest=0;
- sort($times); // I changed the asort to sort here
- foreach ($times as $event) { $time_value = $event[0]; $post_id = $event[1]; $time_key = $event[2]; // changed the foreach here
- if ($time_key == 'opening_time') { ?>
- <li class="sidebar_event">
- <a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_post_thumbnail($post_id, 'upcoming_event_sidebar'); ?></a>
- <h2><a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_title($post_id); ?></a></h2>
- <h3>Opening</h3>
- <h4>
- <?php
- if (get_post_meta($post_id,'event_venue', true) != 'other') {
- echo get_post_meta($post_id,'event_venue', true);
- }
- if (get_post_meta($post_id,'event_venue', true) == 'other') {
- echo get_post_meta($post_id,'custom_event_venue', true);
- }
- ?>
- </h4>
- <h5><?php $opening_time_formated = date($convertedtime, strtotime( get_post_meta($post_id,'opening_time', true)));
- echo $opening_time_formated;?> </h5>
- <hr />
- </li><!-- end .sidebar_event -->
- <?php }
- else if ($time_key == 'artist_talk_time') { ?>
- <li class="sidebar_event">
- <a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_post_thumbnail($post_id, 'upcoming_event_sidebar'); ?></a>
- <h2><a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_title($post_id); ?></a></h2>
- <h3>Artist Talk</h3>
- <h4><?php echo get_post_meta($post_id,'event_venue', true);?> </h4>
- <h5><?php $artist_talk_time_formated = date($convertedtime, strtotime( get_post_meta($post_id,'artist_talk_time', true)));
- echo $artist_talk_time_formated;?> </h5>
- <hr />
- </li><!-- end .sidebar_event -->
- <?php }
- else if ($time_key == 'closing_time') { ?>
- <li class="sidebar_event">
- <a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_post_thumbnail($post_id, 'upcoming_event_sidebar'); ?></a>
- <h2><a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_title($post_id); ?></a></h2>
- <h3>Closing</h3>
- <h4><?php echo get_post_meta($post_id,'event_venue', true);?> </h4>
- <h5><?php echo get_post_meta($post_id,'closing_time', true);?> </h5>
- <hr />
- </li><!-- end .sidebar_event -->
- <?php }
- else if ($time_key == 'special_event_time') { ?>
- <li class="sidebar_event">
- <a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_post_thumbnail($post_id, 'upcoming_event_sidebar'); ?></a>
- <h2><a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_title($post_id); ?></a></h2>
- <h3>Special Event</h3>
- <h4><?php echo get_post_meta($post_id,'event_venue', true);?> </h4>
- <h5><?php $special_event_time_formated = date($convertedtime, strtotime( get_post_meta($post_id,'special_event_time', true)));
- echo $special_event_time_formated;?></h5>
- <hr />
- </li><!-- end .sidebar_event -->
- <?php }
- }
- rewind_posts();
- ?>
- </ul>
- <?php
- }
- ?>
- <br />
- <br />
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement