PHP: Using Week or Month Commencing Layouts In JetEngine

In order to use a layout that includes grouping of posts by either month or week based on an Advanced Custom Fields date we need to edit the way Advanced Custom Fields saves the Date values in the database.

This is because JetEngine can only order by Date and group by Date if the value we’re retrieving from the database is a Unix timestamp, by default Advanced Custom Fields saves it as a string/date object.

We can achieve this with a simple function in our functions.php file or a file that is included in our functions.php file:

add_filter('acf/update_value/type=date_time_picker', 'convert_date_to_timestamp_date_time_picker', 10, 3);
function convert_date_to_timestamp_date_time_picker( $value, $post_id, $field ) {
    return strtotime( $value );
}

Powered by BetterDocs