Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $post;
- // GET search variables from URL
- $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
- $search = get_query_var('s');
- $tax_slug = sanitize_text_field($_GET['tax_id']);
- $venue = sanitize_text_field($_GET['venue']);
- $start_date = sanitize_text_field($_GET['start_date']);
- if($start_date){
- $e_date = date('Y-m-d H:i:s',strtotime("+30 days", strtotime($start_date)));
- $s_date = date('Y-m-d H:i:s',strtotime("-1 day", strtotime($start_date))); // minus one day
- }
- // Setup search array
- $args = array();
- if($search != " "){ $args['s'] = $search; }
- if($venue){ $args['venue'] = (int)$venue; }
- if($s_date){ $args['start_date'] = $s_date; $args['end_date'] = $e_date; }
- $args['posts_per_page'] = 5;
- $args['eventDisplay'] = 'upcoming';
- $args['paged'] = $paged;
- if ($tax_slug == "all") {
- $events = tribe_get_events($args);
- } // end if
- else {
- $args['tax_query'] = array(
- array(
- 'taxonomy' => 'tribe_events_cat',
- 'field' => 'slug',
- 'terms' => $tax_slug
- )
- );
- $events = tribe_get_events($args);
- } // end else
- echo '<pre style="white-space: pre-wrap;">'.print_r($args,true).'</pre>'; // debug array
- if ($events == null){
- echo'<p>Your search returned no results, please try searching again.</p>';
- }else{
- // Events loop
- foreach($events as $post) {
- setup_postdata($post);
- ?>
- <div class="upcoming_events">
- <div class="event_date">
- <span class="calendar_month"><?php echo tribe_get_start_date( $post->ID, false, 'M' ); ?></span>
- <span class="calendar_day"><?php echo tribe_get_start_date( $post->ID, false, 'd' ); ?></span>
- </div>
- <div class="event_desc">
- <h4><a href="<?php echo tribe_event_link(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4>
- <?php the_excerpt(); ?>
- </div><!--event desc-->
- <div class="event_meta">
- <ul>
- <li><span>Start:</span><p><?php echo tribe_get_start_date( $post->ID, true, 'm/d/y ' ); ?></p></li>
- <li><span>End:</span><p><?php echo tribe_get_end_date( $post->ID, true, 'm/d/y ' ); ?></p></li>
- <?php if(tribe_has_venue()){ ?><li><span>Location:</span><p><?php echo tribe_get_venue(); ?></p></li><? } ?>
- <?php if(tribe_address_exists()){ ?><li><span>Address:</span><p><?php echo tribe_get_address(); ?><br /><?php echo tribe_get_city().', '; echo tribe_get_state().' '; echo tribe_get_zip(); ?></p></li><?php } ?>
- <?php if(tribe_get_cost() != ""){ ?><li><span>Cost:</span><p><?php echo tribe_get_cost(); ?></p></li><?php } ?>
- </ul>
- </div><!--event meta-->
- </div><!--upcoming events-->
- <?php } // end foreach
- } // end else
- ?>
Advertisement
Add Comment
Please, Sign In to add comment