1. Home
  2. Knowledge Base
  3. Posts Table Pro
  4. Advanced Usage

How to list only active events using The Events Calendar

Posts Table Pro works beautifully with The Events Calendar plugin for listing events in a searchable table view. We have a full tutorial on how to use the two plugins together.

In The Events Calendar, you can have a start date and an end date for each event. After the end date passes, the event won’t be active anymore. By default, Posts Table Pro shows all events in the table, even past ones. If you want to show only upcoming events, then you can use this code snippet:

add_filter( 'posts_table_query_args', function( $args, $posts_table ) {
    $args['meta_query'] = array(
array(
    'key' => '_EventEndDate',
    'value' =>     date("Y-m-d H:i:s"), 
    'compare'        => '>=',
    'type' => 'date'
    ) ); 
    return $args;
}, 10, 2 );

Please note that these code snippets are aimed at developers. If you feel comfortable using them, our article on how to use code snippets can serve as a helpful guide. If you’re not sure how to use this code then you can use our plugin customization service.

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.