Home › Forums › Add-ons › Repeater Field › Sort by date a repeater field › Reply To: Sort by date a repeater field
Hey @James, thank you for your help.
So I did try the following code you send me, it doesn’t seem to work yet.
Here is what I wrote on my functions.php
<? function my_acf_load_value( $value, $post_id, $field ) {
$order = array();
if( empty($value) ) {
return $value;
}
foreach( $value as $i => $row ) {
$order[ $i ] = strtotime($row['date']);
}
array_multisort( $order, SORT_DESC, $value );
return $value;
}?>
<? add_filter('acf/load_value/name=date', 'my_acf_load_value', 10, 3);?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.