If tribe_events_list_the_date_headers() has output

Home Forums Calendar Products Events Calendar PRO If tribe_events_list_the_date_headers() has output

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1348206
    Josh Kern
    Participant

    In /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; ?>

    #1348821
    Cliff
    Member

    Hi, 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_headers filter. It’s on Line 352 of /wp-content/plugins/the-events-calendar/src/functions/template-tags/loop.php

    In your filter, check if $html is empty. If it’s not, wrap it in your custom HTML.

    Please let me know how this goes for you.

    #1359723
    Support Droid
    Keymaster

    Hey 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

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘If tribe_events_list_the_date_headers() has output’ is closed to new replies.