I use ACF for some fields (as mentionned in that previous discusion: https://toolset.com/fr/forums/topic/output-acf-date-in-views/) and Minesh helped me output the dates in a "human readable format" (j F Y).
But then, I want to have a filter to narrow the results between two dates, but it doesn't work.... When a pick a date either it doens't narrow the search, or it returns nothing...
In the Query filter section, I tried Unsigned, Signed, Date, Chain, Number.... always the same result:
In the Views Search and Pagination, I have this code :
<div class="form-group et_pb_column et_pb_column_1_2">
<div class="form-group"><strong>Départ prévu de la formation</strong><br/>
<label>[wpml-string context="wpv-views"]entre le : [/wpml-string]</label>
[wpv-control-postmeta field="gestion_groupe_0_date_debut" type="date" url_param="_debut1"]
<br>
<label>[wpml-string context="wpv-views"]et le : [/wpml-string]</label>
[wpv-control-postmeta field="gestion_groupe_0_date_debut" type="date" url_param="_debut2"]
</div>
</div>
I used a similar query for another CPT, but with dates picked up in a custom toolset field.
Thanks in advance again 🙂
One more thing 🙂
The shortcode provided in the thread https://toolset.com/fr/forums/topic/output-acf-date-in-views/ doesn't solve entirely my problem :
The shortcode provided tranform the unix timestamp in a readable format. But, if there's no date, it output the date of the present day (as shown in image)....
But then, I want to have a filter to narrow the results between two dates, but it doesn't work..
Hi, there are a couple of issues here:
1. Only simple ACF fields are compatible with Views filters. Date is not a simple field, because dates can be represented in many different formats.
2. ACF date field values are stored in the database as a string like "20181009", but Types date field values are stored as Unix timestamps. Views date filters are designed to work with Unix timestamps like "1539043200", so the ACF date fields are ultimately incompatible with Views filters.
One solution is to create a date field in Types and translate ACF date field values into Types dates in each post, then begin editing the Types date fields in the future instead of the old ACF date fields. In your View, set up the custom filters using the new Types date field instead of the ACF field.
This is a tedious operation if you do it manually in wp-admin and there are many affected posts. A skilled developer might be able to write a script that automates this operation using PHP or MySQL, and that is probably the best approach.