Advertisement
BakerMan

Limit posts per cell table.php

Oct 22nd, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.28 KB | None | 0 0
  1. function display_day( $day, $monthView ) {
  2.     global $post;
  3.     $output = '';
  4.     $posts_per_page = tribe_get_option( 'postsPerPage', 10 );
  5.     $postsPerCell = 3;
  6.  
  7.     if (count($monthView[$day]) < $postsPerCell)
  8.         $postsPerCell = count($monthView[$day]);
  9.  
  10.     for ( $i = 0; $i < $postsPerCell; $i++ ) {
  11.         $post = $monthView[$day][$i];
  12.         setup_postdata( $post );
  13.         $eventId    = $post->ID.'-'.$day;
  14.         $start      = tribe_get_start_date( $post->ID, false, 'U' );
  15.         $end        = tribe_get_end_date( $post->ID, false, 'U' );
  16.         $cost       = tribe_get_cost( $post->ID );
  17.         ?>
  18.         <div id='event_<?php echo $eventId; ?>' <?php post_class('tribe-events-event tribe-events-real-event') ?>>
  19.             <a href="<?php tribe_event_link(); ?>"><?php the_title(); ?></a>
  20.             <div id='tooltip_<?php echo $eventId; ?>' class="tribe-events-tooltip" style="display:none;">
  21.                 <h5 class="tribe-events-event-title"><?php the_title();?></h5>
  22.                 <div class="tribe-events-event-body">
  23.                     <div class="tribe-events-event-date">
  24.                         <?php if ( !empty( $start ) )   echo date_i18n( get_option('date_format', 'F j, Y'), $start);
  25.                         if ( !tribe_get_event_meta($post->ID, '_EventAllDay', true) )
  26.                             echo ' ' . date_i18n( get_option('time_format', 'g:i a'), $start); ?>
  27.                         <?php if ( !empty( $end )  && $start !== $end ) {
  28.                             if ( date_i18n( 'Y-m-d', $start ) == date_i18n( 'Y-m-d', $end ) ) {
  29.                                 $time_format = get_option( 'time_format', 'g:i a' );
  30.                                 if ( !tribe_get_event_meta($post->ID, '_EventAllDay', true) )
  31.                                     echo " – " . date_i18n( $time_format, $end );
  32.                             } else {
  33.                                 echo " – " . date_i18n( get_option('date_format', 'F j, Y'), $end);
  34.                                 if ( !tribe_get_event_meta($post->ID, '_EventAllDay', true) )
  35.                                     echo ' ' . date_i18n( get_option('time_format', 'g:i a'), $end) . '<br />';
  36.                             }
  37.                         } ?>
  38.                     </div>
  39.                     <?php if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) { ?>
  40.                         <div class="tribe-events-event-thumb"><?php the_post_thumbnail( array(75,75));?></div>
  41.                     <?php } ?>
  42.                     <?php echo has_excerpt() ? TribeEvents::truncate($post->post_excerpt) : TribeEvents::truncate(get_the_content(), 30); ?>
  43.  
  44.                 </div>
  45.                 <span class="tribe-events-arrow"></span>
  46.             </div>
  47.         </div>
  48.         <?php
  49.         if( $i < count( $monthView[$day] ) - 1 ) {
  50.             echo "<hr />";
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement