Forum Replies Created
-
AuthorPosts
-
October 31, 2015 at 1:48 am in reply to: List View: Show date on only the first event of the day #1020468
Percy
ParticipantIt 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.
October 29, 2015 at 1:10 pm in reply to: List View: Show date on only the first event of the day #1020020Percy
ParticipantThanks for this Brian.
October 29, 2015 at 9:01 am in reply to: List View: Show date on only the first event of the day #1019816Percy
ParticipantThanks 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
-
AuthorPosts
