How to add a class to links generated by the prev & next event link?

Home Forums Calendar Products Events Calendar PRO How to add a class to links generated by the prev & next event link?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #926206
    Caroline
    Participant

    Hi,

    How do I add a class to the links generated by tribe_the_prev_event_link and tribe_the_next_event_link?

    I tried the adding following code to the functions file, but it didn’t work. Not sure what I’m missing.

    add_filter(‘tribe_the_prev_event_link_attributes’, ‘posts_link_attributes_1’);
    add_filter(‘tribe_the_next_event_link_attributes’, ‘posts_link_attributes_2’);

    function posts_link_attributes_1() {
    return ‘class=”prev-post”‘;
    }
    function posts_link_attributes_2() {
    return ‘class=”next-post”‘;
    }

    #926314
    Geoff
    Member

    Hi there, Caroline! Thanks for getting in touch.

    I think the best way to add a class to the Next and Previous Event links is to do it at the template level. In this case, you can override theย single-event.php file (see more on template overrides in our Themer’s Guide), then add the class name directly to the links. You’ll find these in Lines 45-46 and again in 95-96.

    Will this work for you? Please let me know. ๐Ÿ™‚

    Cheers!
    Geoff

    #927995
    Caroline
    Participant

    Thanks Geoff,

    I managed to solve it:

    function tribe_link_next_class($format){
    $format = str_replace(‘href=’, ‘class=”ss-icon next” href=’, $format);
    return $format;
    }
    add_filter(‘tribe_the_next_event_link’, ‘tribe_link_next_class’);

    function tribe_link_prev_class($format) {
    $format = str_replace(‘href=’, ‘class=”ss-icon prev” href=’, $format);
    return $format;
    }
    add_filter(‘tribe_the_prev_event_link’, ‘tribe_link_prev_class’);

    #927999
    Geoff
    Member

    Awesome job! You’re a rock star–thanks for sharing!

    I’ll go ahead and close this thread but please feel free to holler if anything else pops up–we’d be happy to help. ๐Ÿ™‚

    Geoff

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘How to add a class to links generated by the prev & next event link?’ is closed to new replies.