Home › Forums › Calendar Products › Events Calendar PRO › tribe_events_before_html breaks the next and previous links in some views
- This topic has 4 replies, 2 voices, and was last updated 8 years, 1 month ago by
Adam Thorp.
-
AuthorPosts
-
March 7, 2018 at 4:28 am #1471975
Adam Thorp
ParticipantI’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?
March 8, 2018 at 5:06 am #1473157Victor
MemberHi 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,
VictorMarch 9, 2018 at 1:37 am #1474260Adam Thorp
ParticipantThanks 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.
March 9, 2018 at 9:21 am #1474850Victor
MemberHey 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 -
AuthorPosts
- The topic ‘tribe_events_before_html breaks the next and previous links in some views’ is closed to new replies.
