Home › Forums › Calendar Products › Events Calendar PRO › Change Number of events to show in event list widget pro
- This topic has 13 replies, 2 voices, and was last updated 10 years, 8 months ago by
Geoff.
-
AuthorPosts
-
September 15, 2015 at 1:32 pm #1005397
Sören
ParticipantHi there,
i want to show more than 10 upcoming events in the event list widget. How can i add an value – for example 30 events?
September 16, 2015 at 8:19 am #1005604Geoff
MemberHey @ and welcome back!
Yeah, that can be a little frustrating, can’t it? Try adding this snippet to your theme (or preferably child theme) functions.php file and see if that does the trick. It may not necessarily show the number in the widget settings, but the filter should impact the number of events in the widget itself.
You can change the value in there from “30” to any number. 🙂
Cheers!
GeoffSeptember 16, 2015 at 9:21 am #1005632Sören
ParticipantHi Geoff,
your post is different from my mail i get:
Geoff wrote:
Hey @ and welcome back!
Yeah, that can be a little frustrating, can’t it? Try adding this snippet to your theme (or preferably child theme) functions.php file and see if that does the trick. It may not necessarily show the number in the widget settings, but the filter should impact the number of events in the widget itself.
You can change the value in there from “30” to any number. 🙂
Cheers!
GeoffWhere is he funktions.php file?
Thansk for your answer 🙂
September 16, 2015 at 9:40 am #1005638Geoff
MemberHey Sören!
Your functions.php file should be right in the theme directory. So, for example:
/wp-content/themes/[your-theme]/functions.php
Do you see that in there?
Geoff
September 16, 2015 at 10:20 am #1005650Sören
ParticipantYes, i see that in there but there is no value to change:
<?php /** * @package Helios * @author YOOtheme http://www.yootheme.com * @copyright Copyright (C) YOOtheme GmbH * @license http://www.gnu.org/licenses/gpl.html GNU/GPL */ // check compatibility if (version_compare(PHP_VERSION, '5.3', '>=')) { // bootstrap warp require(__DIR__.'/warp.php'); }September 16, 2015 at 11:18 am #1005683Geoff
MemberSorry for not being clear and I see now that my original snippet got cut out of my first reply altogether! Here’s the full snippet, which you can add to the bottom of your functions.php file. 🙂
add_filter('widget_display_callback', 'increase_event_widget_limit', 10, 2); /** * Test if the current widget is an Advanced List Widget and fix the event limit if it is. */ function increase_event_widget_limit(array $instance, $widget) { if (is_a($widget, 'Tribe__Events__Pro__Advanced_List_Widget')) $instance['limit'] = 30; return $instance; }Cheers!
GeoffSeptember 16, 2015 at 2:05 pm #1005773Sören
ParticipantOkay, it works but i use the widget two times – it’s a one page layout:/
So in the first widget i want to show only the next one and in the second i want to show all events. If i use your code, both widgets are showing 30 events. Hope you have an idea 🙁September 16, 2015 at 2:10 pm #1005778Geoff
MemberInteresting!
I think the best route there would be to use one widget and then add an event query to your page template using the tribe_get_events() function. You can use that to call the next upcoming event rather than using a widget to do that–otherwise, the filter I provided will affect all instances of the widget.
I believe this is about as much as I can do to help with a customization question like this, but I hope that this at least points you in the right direction and I am happy to answer any other questions as best I can.
Thanks!
GeoffSeptember 17, 2015 at 10:50 pm #1006325Sören
ParticipantOkay, i thinks this is not possible to me. If you create the widget, you have 10 values: 1 – 10. Where do they come from and is it possible to manipulate them? Maybee you see the value 10 but it shows 30?
September 18, 2015 at 7:51 am #1006431Geoff
MemberHey Sören,
Yeah, that’s the case even for me: the values will continue to be 1-10 on the back-end, but the snippets acts as a filter on the front-end that forces that value to something else when it gets displayed on the site.
One idea is to modify the snippet in some way that it targets the only one of the widgets. Each widget has a unique ID/Class and it could be possible to wrap the snippet in a conditional statement that looks for one widget over the other. Is that something you think would work?
Geoff
September 19, 2015 at 5:43 am #1006756Sören
ParticipantI think that would work for me, but i have no idea how to modify the snippet :/
September 21, 2015 at 7:49 am #1007026Geoff
MemberI think using is_active_widget() might be a good place to start. I’ll leave this thread open a little while longer to see if others might be able to chime in as well.
Cheers!
GeoffSeptember 21, 2015 at 12:20 pm #1007189Sören
ParticipantA friend of me helped me, here is the solution:
add_filter('widget_display_callback', 'increase_event_widget_limit', 10, 2); /** * Test if the current widget is an Advanced List Widget and fix the event limit if it is. */ function increase_event_widget_limit($instance, $widget) { if (is_a($widget, 'Tribe__Events__Pro__Advanced_List_Widget')) if($instance['limit']==10) $instance['limit'] = 500; return $instance; }September 21, 2015 at 2:49 pm #1007249Geoff
MemberSmart! Another conditional in there to check for the number displayed in another widget. Props and sheers for the solution. 🙂
-
AuthorPosts
- The topic ‘Change Number of events to show in event list widget pro’ is closed to new replies.
