Guest User

list.php

a guest
Jan 19th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.64 KB | None | 0 0
  1. <?php
  2. /**
  3. * The TEC template for a list of events. This includes the Past Events and Upcoming Events views
  4. * as well as those same views filtered to a specific category.
  5. *
  6. * You can customize this view by putting a replacement file of the same name (list.php) in the events/ directory of your theme.
  7. */
  8.  
  9. // Don't load directly
  10. if ( !defined('ABSPATH') ) { die('-1'); }
  11. $load_register = false;
  12. global $wpdb;
  13. ?>
  14. <div id="tribe-events-content" class="upcoming">
  15.  
  16.     <div id="tribe-events-loop" class="tribe-events-events post-list clearfix">
  17.    
  18.     <?php
  19.         $url_args = explode('/',$_SERVER['SCRIPT_URL']);
  20.         switch($url_args[2]){
  21.             case 'upcoming':
  22.                 $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
  23.                             SECOND ) , eventEnd.meta_value ) AS EventEndDate
  24.                             FROM wp_posts
  25.                             LEFT JOIN wp_postmeta AS eventStart ON ( wp_posts.ID = eventStart.post_id
  26.                             AND eventStart.meta_key =  '_EventStartDate' )
  27.                             LEFT JOIN wp_postmeta AS eventDuration ON ( wp_posts.ID = eventDuration.post_id
  28.                             AND eventDuration.meta_key =  '_EventDuration' )
  29.                             LEFT JOIN wp_postmeta AS eventEnd ON ( wp_posts.ID = eventEnd.post_id
  30.                             AND eventEnd.meta_key =  '_EventEndDate' )
  31.                             WHERE 1 =1
  32.                             AND wp_posts.post_type =  'tribe_events'
  33.                             AND (
  34.                             wp_posts.post_status =  'publish'
  35.                             OR wp_posts.post_status =  'private'
  36.                             )
  37.                             AND eventStart.meta_value > '" . date('Y-m-d h:i:s',strtotime('-1 day')) . "'
  38.                             ORDER BY EventStartDate ASC";
  39.                 $page_title = 'Upcoming Events';
  40.             break;
  41.             default:   
  42.                 $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
  43.                             SECOND ) , eventEnd.meta_value ) AS EventEndDate
  44.                             FROM wp_posts
  45.                             LEFT JOIN wp_postmeta AS eventStart ON ( wp_posts.ID = eventStart.post_id
  46.                             AND eventStart.meta_key =  '_EventStartDate' )
  47.                             LEFT JOIN wp_postmeta AS eventDuration ON ( wp_posts.ID = eventDuration.post_id
  48.                             AND eventDuration.meta_key =  '_EventDuration' )
  49.                             LEFT JOIN wp_postmeta AS eventEnd ON ( wp_posts.ID = eventEnd.post_id
  50.                             AND eventEnd.meta_key =  '_EventEndDate' )
  51.                             WHERE 1 =1
  52.                             AND wp_posts.post_type =  'tribe_events'
  53.                             AND (
  54.                             wp_posts.post_status =  'publish'
  55.                             OR wp_posts.post_status =  'private'
  56.                             )
  57.                             ORDER BY wp_posts.post_title ASC";
  58.                 $page_title = 'All Events';
  59.         }
  60.    
  61.         //var_dump($args);
  62.         echo '<h2 class="story_title">' . $page_title . '</h2>';
  63.    
  64.         // Reset Post Data
  65.         wp_reset_query();
  66.         wp_reset_postdata();
  67.    
  68.    
  69.         //$the_query = new WP_Query( $args );
  70.        
  71.  
  72.         //var_dump($querystr);
  73.        
  74.          $pageposts = $wpdb->get_results($querystr, OBJECT);
  75.          if($pageposts){
  76.          global $post;
  77.         // The Loop
  78.         //while ( have_posts() ) : the_post();
  79.         foreach($pageposts as $post){
  80.         setup_postdata($post);
  81.         ?>
  82.    
  83.             <div class="tribe_event_teaser">
  84.                 <div class="te_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
  85.                 <div class="te_date"><?php echo tribe_get_start_date( null, false, 'D, F jS, Y' ); ?></div>
  86.                 <div class="te_venue">
  87.                 <?php
  88.                     if( tribe_address_exists( get_the_ID() ) ){
  89.                         echo tribe_get_city( get_the_ID() ) . ', ' . tribe_get_state( get_the_ID() );
  90.                     }
  91.                 ?>
  92.                 </div>
  93.                 <div class="clearfix"></div>
  94.             </div>
  95.         <?php }
  96.        
  97.         }
  98.         // Reset Post Data
  99.         wp_reset_postdata();
  100.    
  101.     ?>
  102.  
  103.  
  104.     </div><!-- #tribe-events-loop -->
  105. </div>
Advertisement
Add Comment
Please, Sign In to add comment