Category Widget – Show Post Counts

WordPress Event Management, Calendars & Registration Forums General Question Category Widget – Show Post Counts

This topic contains 3 replies, has 2 voices, and was last updated by  Stephen Harris 10 years, 6 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7833

    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
    #7841

    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
    #7876

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

    scott stafstrom
    #7950

    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.


    1. Since 2.4 is about to be released (today/tomorrow). I think this change will be held back until 2.5. The bug regarding the filter name will be fixed in 2.4. 

    • This reply was modified 10 years, 6 months ago by  Stephen Harris.
    • This reply was modified 10 years, 6 months ago by  Stephen Harris.
    Stephen Harris
Viewing 4 posts - 1 through 4 (of 4 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.