Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * The TEC template for a list of events. This includes the Past Events and Upcoming Events views
- * as well as those same views filtered to a specific category.
- *
- * You can customize this view by putting a replacement file of the same name (list.php) in the events/ directory of your theme.
- */
- // Don't load directly
- if ( !defined('ABSPATH') ) { die('-1'); }
- $load_register = false;
- global $wpdb;
- ?>
- <div id="tribe-events-content" class="upcoming">
- <div id="tribe-events-loop" class="tribe-events-events post-list clearfix">
- <?php
- $url_args = explode('/',$_SERVER['SCRIPT_URL']);
- switch($url_args[2]){
- case 'upcoming':
- $querystr = "SELECT SQL_CALC_FOUND_ROWS wp_posts. * , eventStart.meta_value AS EventStartDate, IFNULL( DATE_ADD( CAST( eventStart.meta_value AS DATETIME ) , INTERVAL eventDuration.meta_value
- SECOND ) , eventEnd.meta_value ) AS EventEndDate
- FROM wp_posts
- LEFT JOIN wp_postmeta AS eventStart ON ( wp_posts.ID = eventStart.post_id
- AND eventStart.meta_key = '_EventStartDate' )
- LEFT JOIN wp_postmeta AS eventDuration ON ( wp_posts.ID = eventDuration.post_id
- AND eventDuration.meta_key = '_EventDuration' )
- LEFT JOIN wp_postmeta AS eventEnd ON ( wp_posts.ID = eventEnd.post_id
- AND eventEnd.meta_key = '_EventEndDate' )
- WHERE 1 =1
- AND wp_posts.post_type = 'tribe_events'
- AND (
- wp_posts.post_status = 'publish'
- OR wp_posts.post_status = 'private'
- )
- AND eventStart.meta_value > '" . date('Y-m-d h:i:s',strtotime('-1 day')) . "'
- ORDER BY EventStartDate ASC";
- $page_title = 'Upcoming Events';
- break;
- default:
- $querystr = "SELECT SQL_CALC_FOUND_ROWS wp_posts. * , eventStart.meta_value AS EventStartDate, IFNULL( DATE_ADD( CAST( eventStart.meta_value AS DATETIME ) , INTERVAL eventDuration.meta_value
- SECOND ) , eventEnd.meta_value ) AS EventEndDate
- FROM wp_posts
- LEFT JOIN wp_postmeta AS eventStart ON ( wp_posts.ID = eventStart.post_id
- AND eventStart.meta_key = '_EventStartDate' )
- LEFT JOIN wp_postmeta AS eventDuration ON ( wp_posts.ID = eventDuration.post_id
- AND eventDuration.meta_key = '_EventDuration' )
- LEFT JOIN wp_postmeta AS eventEnd ON ( wp_posts.ID = eventEnd.post_id
- AND eventEnd.meta_key = '_EventEndDate' )
- WHERE 1 =1
- AND wp_posts.post_type = 'tribe_events'
- AND (
- wp_posts.post_status = 'publish'
- OR wp_posts.post_status = 'private'
- )
- ORDER BY wp_posts.post_title ASC";
- $page_title = 'All Events';
- }
- //var_dump($args);
- echo '<h2 class="story_title">' . $page_title . '</h2>';
- // Reset Post Data
- wp_reset_query();
- wp_reset_postdata();
- //$the_query = new WP_Query( $args );
- //var_dump($querystr);
- $pageposts = $wpdb->get_results($querystr, OBJECT);
- if($pageposts){
- global $post;
- // The Loop
- //while ( have_posts() ) : the_post();
- foreach($pageposts as $post){
- setup_postdata($post);
- ?>
- <div class="tribe_event_teaser">
- <div class="te_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
- <div class="te_date"><?php echo tribe_get_start_date( null, false, 'D, F jS, Y' ); ?></div>
- <div class="te_venue">
- <?php
- if( tribe_address_exists( get_the_ID() ) ){
- echo tribe_get_city( get_the_ID() ) . ', ' . tribe_get_state( get_the_ID() );
- }
- ?>
- </div>
- <div class="clearfix"></div>
- </div>
- <?php }
- }
- // Reset Post Data
- wp_reset_postdata();
- ?>
- </div><!-- #tribe-events-loop -->
- </div>
Advertisement
Add Comment
Please, Sign In to add comment