Guest User

TEC List of Events

a guest
Jan 19th, 2012
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.04 KB | None | 0 0
  1. /**
  2. * The TEC template for a list of events. This includes the Past Events and Upcoming Events views
  3. * as well as those same views filtered to a specific category.
  4. *
  5. * You can customize this view by putting a replacement file of the same name (list.php) in the events/ directory of your theme.
  6. */
  7.  
  8. // Don't load directly
  9. if ( !defined('ABSPATH') ) { die('-1'); }
  10. $load_register = false;
  11. ?>
  12. <div id="tribe-events-content" class="upcoming">
  13.  
  14.     <div id="tribe-events-loop" class="tribe-events-events post-list clearfix">
  15.    
  16.     <?php
  17.         $url_args = explode('/',$_SERVER['SCRIPT_URL']);
  18.         switch($url_args[2]){
  19.             case 'upcoming':
  20.                 $args = array(
  21.                     'post_type' => 'tribe_events',
  22.                     'orderby' => 'meta_value_num',
  23.                     'meta_key' => '_EventStartDate',
  24.                     'order' => 'ASC',
  25.                     'meta_query' => array(
  26.                         'key' => '_EventStartDate',
  27.                         'value' => date('Y-m-d h:i:s',strtotime("-1 day")),
  28.                         'compare' => '>'
  29.                     )
  30.                 );
  31.                 $page_title = 'Upcoming Events';
  32.             break;
  33.             default:   
  34.                 $args = array(
  35.                     'post_type' => 'tribe_events',
  36.                     'orderby' => 'title',
  37.                     'order' => 'ASC'
  38.                 );
  39.                 $page_title = 'All Events';
  40.         }
  41.    
  42.         var_dump($args);
  43.         echo '<h2 class="story_title">' . $page_title . '</h2>';
  44.    
  45.         // Reset Post Data
  46.         wp_reset_query();
  47.         wp_reset_postdata();
  48.    
  49.         $the_query = new WP_Query( $args );
  50.        
  51.         var_dump($the_query);
  52.        
  53.  
  54.         // The Loop
  55.         while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
  56.    
  57.             <div class="tribe_event_teaser">
  58.                 <div class="te_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
  59.                 <div class="te_date"><?php echo tribe_get_start_date( null, false, 'D, F jS, Y' ); ?></div>
  60.                 <div class="te_venue">
  61.                 <?php
  62.                     if( tribe_address_exists( get_the_ID() ) ){
  63.                         echo tribe_get_city( get_the_ID() ) . ', ' . tribe_get_state( get_the_ID() );
  64.                     }
  65.                 ?>
  66.                 </div>
  67.                 <div class="clearfix"></div>
  68.             </div>
  69.         <?php endwhile;
  70.  
  71.         // Reset Post Data
  72.         wp_reset_postdata();
  73.    
  74.     ?>
  75.  
  76.  
  77.     </div><!-- #tribe-events-loop -->
  78. </div>
Advertisement
Add Comment
Please, Sign In to add comment