// First, we filter the meta_query in our query that fetches events and tell it to look for posts where

// the meta field 'custom_event_start' isn't blank.

// custom_event_start could be any meta key you want, but it should contain a

// properly formatted date/time (e.g. the default date format for ACF date/time // fields works fine)




add_filter(

"piecal_event_query_args",

function ($args, $atts) {

$args["meta_query"] = [

"relation" => "AND",

        [

            "key" => "custom_event_start",

            "value" => "",

            "compare" => "!=",

        ],

    ];




    return $args;

},

10,

2




);

// Next, we need to tell Pie Calendar to look at our 'custom_event_start' meta key for the start date.

add_filter("piecal_start_date_meta_key", function ($key) {

$key = "custom_event_start";

return $key;




});

// Finally, we tell Pie Calendar to look at our 'custom_event_end' meta key for the end date.

add_filter("piecal_end_date_meta_key", function ($key) {

$key = "custom_event_end";

return $key;




});