Is there a way to add post counts as an option to the Event Category Widget? I want to avoid having my site visitors clicking on a category with no current events. I have been working on adding post counts by using some of the code from wp-core widget.php and have not had success. Basically I would like to duplicate the standard WordPress Category Widget options in the Event Category Widget. Thank you for any help.

scott stafstrom
Hi Scott,
I’ll look into this and get back to you. Currently events are “counted” (WordPress by default counts how many posts appear in a taxonomy). But by default this counts the number of distinct events (as opposed to dates/occurrences) and includes past events too. That’s largely due to the fact that the plug-in has never made this a feature so as to alter WordPress default behaviour on this.

Stephen Harris
Thank you Stephen, for your reply and for taking a look at the possibility.
Scott

scott stafstrom
If displaying a list of categories there is a filter (see source that allows you to show the event count. (if using a drop-down, there is also a filter, but this is currently incorrect in that the the name of the filter is wrong, and will be fixed int the next update).
add_filter( 'eventorganiser_widget_event_categories_args', 'scott_display_event_category_count' );
function scott_display_event_category_count( $args ){
$args['show_count'] = 1;//Set show_count to 1.
return $args;
}
However, as a noted above, this will count distinct ‘events’ (i.e. not occurrences) and will count past events too. Since this count is used in the category admin page, it may be confusing to change this behavior. But if I do1 I’ll change it to count events according to the plug-in settings (i.e. whether or not past events are shown and whether occurrences of recurring events are grouped). Regardless I’ll provide a way of over-riding how the events are counted for any given category.
-
This reply was modified 11 years, 4 months ago by
Stephen Harris.
-
This reply was modified 11 years, 4 months ago by
Stephen Harris.

Stephen Harris