Change Number of events to show in event list widget pro

Home Forums Calendar Products Events Calendar PRO Change Number of events to show in event list widget pro

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1005397
    Sören
    Participant

    Hi 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?

    #1005604
    Geoff
    Member

    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!
    Geoff

     

    #1005632
    Sören
    Participant

    Hi 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!
    Geoff

    Where is he funktions.php file?

    Thansk for your answer 🙂

    #1005638
    Geoff
    Member

    Hey 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

    #1005650
    Sören
    Participant

    Yes, 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');
    }
    
    #1005683
    Geoff
    Member

    Sorry 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!
    Geoff

    #1005773
    Sören
    Participant

    Okay, 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 🙁

    http://www.xn--hkken-gra.de/

    #1005778
    Geoff
    Member

    Interesting!

    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!
    Geoff

    #1006325
    Sören
    Participant

    Okay, 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?

    #1006431
    Geoff
    Member

    Hey 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

    #1006756
    Sören
    Participant

    I think that would work for me, but i have no idea how to modify the snippet :/

    #1007026
    Geoff
    Member

    I 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!
    Geoff

    #1007189
    Sören
    Participant

    A 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;
    }
    #1007249
    Geoff
    Member

    Smart! Another conditional in there to check for the number displayed in another widget. Props and sheers for the solution. 🙂

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Change Number of events to show in event list widget pro’ is closed to new replies.