• The Event list date filter operates on the post date rather than the event date. I would like to extend the filters using hooks and have created code in my custom plugin that displays a dropdown on the events list page similar to the existing date filter. This is called using:

    add_action(‘restrict_manage_posts’,’add_date_filter_to_ai1ec_events’);

    The intent is to alter the query using the filter below. What I don’t know is the proper date format and the name of the variable to be posted in the address bar so the filter will work with the ai1ec query.

    Question: What is the correct variable name to write in the address bar with associated date format so the ai1ec query can retrieve it with a $_GET?

    If this action and filter approach won’t work, or there is another approach that works, please let me know.

    Below is the filter where I used the variable name ai1ec_event_date and assumed formats for date and month.

    
    //this hook will alter the main query according to the user's selection of the custom filter created above:
        add_filter( 'parse_query', function($query){
            global $pagenow;
    	global $post_type;
    
            if ($post_type == 'ai1ec_event' && $pagenow=='edit.php' && isset($_GET['ai1ec_event_date']) && !empty($_GET['ai1ec_event_date']) &&  $_GET['ai1ec_event_date'] !== "-1") {
                $query->query_vars['year'] = substr($_GET['ai1ec_event_date'],0,4);
                $query->query_vars['monthnum'] = substr($_GET['ai1ec_event_date'],4,2);
            }
        });
    

    [Moderator note: Please, No bumping].

  • The topic ‘Filter Event List by Event Date in Admin Area’ is closed to new replies.