1. Home
  2. Posts Table Pro
  3. 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 );

You should paste this code in the functions.php file of your theme or child theme. If you’re not sure how to use this code then you should ask your developer, or post a job on Codeable to find a WordPress expert who can do it for you.

We've partnered with Codeable to provide our customers with expert help if required.

Related Articles

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