Support

Account

Home Forums Front-end Issues sorting entries in repeater post object field Reply To: sorting entries in repeater post object field

  • Hi @rudtek

    You need to get the post title for the order sort. It should be something like this:

    function my_acf_sort_post_object( $value, $post_id, $field ) {
    	
    	// vars
    	$order = array();
    	
    	// bail early if no value
    	if( empty($value) ) {
    		return $value;	
    	}
    	
    	// populate order
    	foreach( $value as $i => $post_id ) {
            $post_title = get_the_title($post_id);
    		$order[ $i ] = $post_title;
    	}
        
        $order_lowercase = array_map('strtolower', $order);
    	
    	// multisort
    	array_multisort( $order_lowercase, SORT_ASC, SORT_STRING, $value );
    	
    	// return	
    	return $value;	
    }
    
    add_filter('acf/load_value/name=session_speaker', 'my_acf_sort_post_object', 10, 3);

    Could you please test it out?

    I hope this helps 🙂