Support

Account

Home Forums Add-ons Repeater Field repeater dates arranged by months title Reply To: repeater dates arranged by months title

  • Hi @felix007

    If you want to sort the dates based on month and hide the past months, you can use this code:

    $repeater = get_field('repeater_field_name');
    
    $order = array();
    
    // populate order
    foreach( $repeater as $i => $row ) {
    	
    	$order[ $i ] = (int) substr($row['date_field_name'],3 ,2);
        
    }
    
    array_multisort( $order, SORT_DESC, $repeater );
    
    foreach( $repeater as $row ) {
    	
        if((int) substr($row['date_field_name'],3 ,2) >= (int) date('m')){
            echo $row['tr1_date1'];
        }
        
    }

    I hope this helps.