• Scratching my head again… There was this great solution posted by Peter to get ACF date picker fields save values as timestamps into the database: https://wordpress.org/support/topic/before-and-after-for-date-fields-anyone-getting-it-to-work/#post-11240427

    It works perfectly for fields that are set for custom post types. I’m not sure if it’s due to the snippet or how I’m calling the fields with shortcode, but I’m not getting the output to be timestamps when the field is a custom field for a taxonomy.

    Been trying [taxonomy taxonomy_name field=date_field] also tried [taxonomy taxonomy_name acf_date=date_field] and adding date_format='U', but having no luck.

    I’m assuming this might be due to the snippet is not actually doing anything for the taxonomy custom field. As the output is always dd/mm/yyyy

    Anyone have any experience with date fields associated with taxonomies?

Viewing 6 replies - 1 through 6 (of 6 total)
  • try

    [taxonomy taxonomy_name acf_date=date_field date_format=U]

    without the ”

    Thread Starter finnfin

    (@finnfin)

    Thanks! Unfortunately I don’t think snippet actually works for this field for some reason, because acf_field= doesn’t return anything. And [taxonomy taxonomy_name field=date_field date_format=U] doesn’t work either unfortunately 🙁

    Yeah, just looked at the snippet – it does not fill your field. See:

    function acf_load_as_acf_date( $value, $post_id, $field )

    You would need to change this part to work with taxonomies.

    Thread Starter finnfin

    (@finnfin)

    I thought since the function isn’t defining any post ID it would work for all date picker fields, regardless what post type or taxonomy it’s in. But does look like it’s not actually updating the value at all in this particular field.

    Its not defining any post-id, it uses the current one.

    Thread Starter finnfin

    (@finnfin)

    Tried changing it to
    function save_as_wp_date( $value, $term_id, $field )
    and same for the load function, but after saving the field, the field always reloads as August 25 1971. Which I don’t even understand, January 1st 1970 would make more sense.
    Need to figure out how to pass the term_id properly I guess.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Taxonomy custom date field into timestamp’ is closed to new replies.