Events List Widget – Modify wp_query

Home Forums Calendar Products Events Calendar PRO Events List Widget – Modify wp_query

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #177564
    barn2media
    Participant

    Hello,

    We’re using the Events List Widget throughout the Event Category pages and we’d like the widget to display only the events within the current category.

    There is a manual setting in the Widget options to select the event category but I’m wondering if there is a filter applied to the widget query so I can automatically set the events category based on the page the user is on?

    If there is a filter this would be much easier than duplicating the widget as a separate plugin as we’d be doing all this just to amend the taxonomy. But this is what we’d need to do to avoid modify the core code of the plugin.

    Many thanks for your help,
    Steven

    #181393
    Barry
    Member

    Hi Steven,

    Anything is possible!

    You could simply use WordPress’s existing widget_display_callback filter and change the instance properties accordingly – the basic form of something like this would be:

    add_filter( 'widget_display_callback', 'customize_list_widget', 10, 3 );
    
    function customize_list_widget( $instance, $widget, $args ) {
    	if ( 'tribe-events-adv-list-widget' !== $widget->id_base ) return $instance;
    	if ( ! tribe_is_event_category() ) return $instance;
    
    	// Insert your logic to set the category here, ie:
    	// $instance['category'] = 4096;
    
    	return $instance;
    }

    Do bear in mind though that some changes are afoot and the next release will incorporate a new way of specifying multiple categories/tags to filter the result set – rather as the calendar widget currently works – so you may need to adjust your solution at that point.

    I hope that helps 🙂

    #701525
    Barry
    Member

    Hi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Events List Widget – Modify wp_query’ is closed to new replies.