Home › Forums › Calendar Products › Events Calendar PRO › If tribe_events_list_the_date_headers() has output
- This topic has 3 replies, 2 voices, and was last updated 8 years, 7 months ago by
Josh Kern.
-
AuthorPosts
-
September 12, 2017 at 11:06 am #1348206
Josh Kern
ParticipantIn /the-events-calendar/src/views/list/loop.php, I’d like to add a container around tribe_events_list_the_date_headers if there’s output. I don’t want empty containers if there’s no output, so the divs and tribe_events_list_the_date_headers need to be within an if statement. Is there an easy way to handle this? Right now, I’m able to achieve this by bringing most of the tribe_events_list_the_date_headers function into the template. Is there a better way?
<?php
$show_headers = apply_filters( 'tribe_events_list_show_date_headers', true );if ( $show_headers ) {
global $post, $wp_query;
$event_year = tribe_get_start_date( $post, false, 'Y' );
$event_month = tribe_get_start_date( $post, false, 'm' );
$month_year_format = tribe_get_date_option( 'monthAndYearFormat', 'F Y' );if ( $wp_query->current_post > 0 ) {
$prev_post = $wp_query->posts[ $wp_query->current_post - 1 ];
$prev_event_year = tribe_get_start_date( $prev_post, false, 'Y' );
$prev_event_month = tribe_get_start_date( $prev_post, false, 'm' );
}}
?><?php if ( $wp_query->current_post === 0 || ( $prev_event_month != $event_month || ( $prev_event_month == $event_month && $prev_event_year != $event_year ) ) ) : ?>
<div class="et_pb_row">
<?php tribe_events_list_the_date_headers(); ?>
</div> <!-- .et_pb_row --><?php endif; ?>
September 13, 2017 at 1:00 pm #1348821Cliff
MemberHi, Josh.
It looks like you just want to wrap `<div class=”et_pb_row”>
</div> <!– .et_pb_row –>` around<?php tribe_events_list_the_date_headers(); ?>— only if it’s not empty.I’d suggest instead using the
tribe_events_list_the_date_headersfilter. It’s on Line 352 of /wp-content/plugins/the-events-calendar/src/functions/template-tags/loop.phpIn your filter, check if
$htmlis empty. If it’s not, wrap it in your custom HTML.Please let me know how this goes for you.
October 5, 2017 at 9:35 am #1359723Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘If tribe_events_list_the_date_headers() has output’ is closed to new replies.
