Percy

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: List View: Show date on only the first event of the day #1020468
    Percy
    Participant

    It worked!

    In case anyone else needs this, here’s the modded code for list/loop.php. Look for “Start listview date mod” in the code comments:

    	<?php while ( have_posts() ) : the_post(); ?>
    		<!-- Month / Year Headers -->
    		<?php tribe_events_list_the_date_headers(); ?>
    	<!-- Start listview date mod part 1/2 -->	
    		<!-- Get Event ID (same as post ID in WP) -->
    		<?php $event_id = get_the_ID(); ?> 
    		<!-- Convert Event ID  to human readable date-->
    		<?php $startDate = strtotime( get_post_meta( $event_id, '_EventStartDate', True ) );
    		    $startDate  = date( 'l F jS', $startDate ); ?>
    		<?php do_action( 'tribe_events_inside_before_loop' ); ?>
    		<!-- Compare $test to $startDate and only publish if theylre different -->
    		<?php if($test	!=$startDate): ?>
    		<h2 class="event-date-once" ><?php echo $startDate;?></h2>
    		<?php endif; ?>
    	<!-- End listview date mod part 1/2 -->		
    
    		<!-- Event  -->
    		<?php
    		$post_parent = '';
    		if ( $post->post_parent ) {
    			$post_parent = ' data-parent-post-id="' . absint( $post->post_parent ) . '"';
    		}
    		?>
    		<div id="post-<?php the_ID() ?>" class="<?php tribe_events_event_classes() ?>" <?php echo $post_parent; ?>>
    			
    			<?php tribe_get_template_part( 'list/single', 'event' ) ?>
    		</div><!-- .hentry .vevent -->
    
    		<?php do_action( 'tribe_events_inside_after_loop' ); ?>
    	<!-- Start listview date mod part 2/2 -->	
    		<!-- pass startDate into a variable $test that will be used to compare to the new $startDate at the top of the loop.  Only dates that differ will publish -->
    		<?php $test = $startDate?>
    	<!-- End listview date mod part 2/2 -->	
    	<?php endwhile; ?>
    

    And here’s the code that strips the date away as well as the ‘@’ (leaving only the start and end time of the event)– add it to list/single-event.php:

    <!-- Removes Date info and publishes time only -->
    <div class="updated published time-details">
    	<?php $stripDate =  tribe_events_event_schedule_details() ?>
    	<?php $stripDate =  strstr($stripDate, '@');
    	$stripDate = str_replace("@", "", $stripDate);
    	echo $stripDate;
    	 ?>
    
    </div>
    

    I did not accommodate for events that span from one day to another nor events that span over several days. We don’t seem to need that at the moment.

    Thanks for steering me in the right direction.

    • This reply was modified 10 years, 6 months ago by Percy. Reason: typos
    • This reply was modified 10 years, 6 months ago by Percy.
    in reply to: List View: Show date on only the first event of the day #1020020
    Percy
    Participant

    Thanks for this Brian.

    in reply to: List View: Show date on only the first event of the day #1019816
    Percy
    Participant

    Thanks for the reply Brian. I’d be interested to hear any clues you might have as to which functions would need to be modded to achieve this.

    I already looked at list/loop.php and list/single-event.php but couldn’t find anything specific enough, so I’m guessing it’s in a function.

    Thanks

Viewing 3 posts - 1 through 3 (of 3 total)