Order posts by meta_value where date is french(other) format


I’m trying to order posts by date (event) using meta_value.
meta_value contain date in french format dd/mm/YYYY.

The only way that I know to get the value of meta_value is like that : ‘meta-value’ => ”,

How can I use the default value inside date() function ?
Something like that : ‘meta-value’ => date(‘Y-m-d’, ”), ? doesn’t work

Is there any way to use the default value from meta_value ?

Here is my args :

$datenow  = strftime("%Y-%m-%d");;
    $asso_args = array(
                        'post_type' => 'post',
                        'meta_key' => 'date',
                        'orderby' => 'meta_value',
                        'order'=> 'ASC',
                        'numberposts' => 3,
                        'posts_per_page' => 3,
                        'tax_query' => array(
                                'taxonomy' => 'post_tag',
                                'field' => 'name',
                                'terms' => $id_asso
                        'meta_query' => array(
                                   'key' => 'date',
                                   'type'=> 'DATE',
                                   'meta_value' => convert default value '' whith date('Y-m-d') ,
                                   'value' => $datenow,
                                   'compare' => '>=',
                                   //'type' => 'CHAR'

I don’t want to use normal format inside meta value ‘date’ because I or other user must add date by the french format inside wordpress admin post.

Even, is it possible to automatically convert the date of metabox when it’s stored in database when in save my post ?
for ex : I whrite 12/01/2021 in metabox, i save my post and automaticaly the date format change to 2021/01/12.

If there are no solutions, is it possible to order posts by it meta_value date after getting args ?

imagIne 2 years 2020-12-30T08:11:06-05:00 0 Answers 2 views 0

Leave an answer