As I wrote in a comment, I donβt know wordpress and maybe something is wrong, but the idea may be fine.
If possible, you can collect all the messages first and then sort them.
To group them, use a temporary array in which you retrieve the objects. Therefore, do not output the div into the array, but "buffer" in the array.
For example, if the array name is $posts , you can do in your foreach : (I hope that in the line with the_sub_field('news_description'); you skipped echo , in this case it will not work)
$var = &$posts[]; // this creates a new item in array, and $var is this element $var->description = the_sub_field('news_description'); // ***** $var->title = the_title(); $var->date = ... // it is important, I don't know if you have it
So, at the end, your array will have all messages from all users (or profiles). Now collect it, for example, using the usort function . You will need to write your own sort function, in the manual it is "cmp", so I use the same name:
function cmp($a, $b){ if($a->date > $b->date) return 1; elseif($a->date < $b->date) return -1; else return 0; }
and name him
usort($posts, 'cmp');
Then you need to output the array to another foreach .
But, as I said, I do not know if Wordpress allows this.