Display Pie Calendar Meta Fields in Admin Edit Screens via Admin Columns

It might be helpful to display Pie Calendar's meta fields such as _piecal_start_date in your WP admin post edit screens.

To do this, we recommend the free Admin Columns plugin to display the custom meta key.

Here's an example of how that works on the Admin Columns side:

When you add that admin column, you can then browse to your post edit screen and see the date and time displayed:

As you can see, the date format Pie Calendar uses is a global standard, but not one that's easily readable by humans.

Luckily Admin Columns gives us a filter we can tap into to reformat the date. Pick from one of the two custom code snippets below and add it to your theme's functions.php file, or to a custom code snippets plugin.

Option One

This snippet formats the dates like: May 6, 2024, 3:29 pm

function format_piecal_admin_start_date($value, $id) {
    $iso_date = get_post_meta($id, '_piecal_start_date', true);
    if ($iso_date) {
        $formatted_date = date('F j, Y, g:i a', strtotime($iso_date));
        return $formatted_date;
    }

    return $value;
}

add_filter('ac/column/value', 'format_piecal_admin_start_date', 10, 2);

Option Two

This snippet forms the dates like: 06/05/2024, 15:29 (dd/mm/yyyy)

function format_piecal_admin_start_date($value, $id) {
    $iso_date = get_post_meta($id, '_piecal_start_date', true);

    if ($iso_date) {
        $formatted_date = date('d/m/Y, H:i', strtotime($iso_date));
        return $formatted_date;
    }

    return $value;
}

add_filter('ac/column/value', 'format_piecal_admin_start_date', 10, 2);

After you've selected one of those two snippets, your admin column will now display the reformatted time and date like this:

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.