Support

Account

Home Forums Front-end Issues ACF Date and Time Format Differs When Used in List Category Posts Shortcode

Unread

ACF Date and Time Format Differs When Used in List Category Posts Shortcode

  • The date (j F Y) and time (H:i) format set in ACF differs when we use it in the “List category posts” shortcode.

    In the ACF (custom fields) plugin it’s set to the above mentioned, which works fine when using [acf field="webinar_date"] in example. Whenever we try to implement it the List Categor Posts shortcode, the date displays as YYYYMMDD (20230316 instead of 16 March 2023) and the time as HH:MM:SS (16:00:00 instead of just 16:00).

    The List Category Posts shortcode used, is as follows:
    [catlist excerpt=yes excerpt_size=20 id=91 pagination=yes numberposts=10 posts_morelink=”Register” customfield_display=”yes” customfield_display=”webinar_date,webinar_sast_start_time,webinar_sast_end_time,webinar_est_start_time,webinar_est_end_time” customfield_display_name=”no” customfield_display_separately=”yes”]

    Is there any way to fix this? We have tried numerous suggestions found online. The last solution we tried, is by including the below mentioned code in the functions.php file (via the Code Snippet plugin):
    function acf_smart_dates($field) {
    if ($field[‘webinar_date’]) {
    $field[‘webinar_date’] = date(‘dmY’,strtotime($field[‘webinar_date’]));
    }
    return $field;
    }
    add_filter(‘acf/prepare_field/type=date_picker’,’acf_smart_dates’);

    Thank you in advance for any suggestions.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.