tribe_events_before_html breaks the next and previous links in some views

Home Forums Calendar Products Events Calendar PRO tribe_events_before_html breaks the next and previous links in some views

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1471975
    Adam Thorp
    Participant

    I’ve tried adding a list of categories above the category view. The code I’ve added works fine for adding the code but, it stops the ‘next’ and ‘previous’ links working on the ‘photo’, ‘month’, and ‘week’ views (It may affect more but I’ve not tested further). The list view still works as expected.

    // This adds a category switcher but breaks the next and previous links in some event category views :(
    add_filter( 'tribe_events_before_html', 'custom_events_before_html', 10 );
    function custom_events_before_html() {
    if ( tribe_is_event_category() ) {
    $args = array(
    'taxonomy' => 'tribe_events_cat',
    'title_li' => '',
    'hierarchical' => 1,
    );
    echo '<nav class="filters"><ul class="inline-block vmiddle filter menu"><li class="menu-item-has-children dropdown"><a href="#category">Change Event category</a><ul class="sub-menu">';
    wp_list_categories( $args );
    echo '</ul></li></ul></nav>';
    }
    }

    I thought for a while it was relating to my code but, when I take all of my code out and leaving an empty function it still broke the next and prev links.

    Any idea what this is breaking and how I can avoid it?

    #1473157
    Victor
    Member

    Hi Adam!

    Thanks for getting in touch with us! Let me help you with this topic.

    The ‘tribe_events_before_html’ is a filter and expects something to be returned, not echoed. So the correct way to use it would be something like:

    add_filter( 'tribe_events_before_html', 'custom_events_before_html', 10 );
    function custom_events_before_html( $before ) {
    //do something with $before
    return $before;
    }

    If you need to echo something you should do so in an action hook like the ‘tribe_events_before_template’.

    Let me point you to the following article where George gives some great tips for working with actions and filters > https://theeventscalendar.com/tips-working-wordpress-actions-filters/

    I hope that helps. 🙂

    Best,
    Victor

    #1474260
    Adam Thorp
    Participant

    Thanks so much. That makes perfect sense. I’ve not got it working yet but, now I understand the issue I don’t think it’ll take long.

    #1474850
    Victor
    Member

    Hey Adam!

    Happy to be of help here! 🙂

    I’ll close this thread now, but feel free to open a new topic if anything comes up and we’ll be happy to help.

    Good luck with your project!
    Victor

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘tribe_events_before_html breaks the next and previous links in some views’ is closed to new replies.