Answer Version 2
I apologize for the confusion.
Here’s how you can use the usort()
function to sort the images (in the div#pic-con
on the front-end):
<div id="pic-con">
<?php
if (!empty($vid_pix)) {
usort( $vid_pix, function( $a, $b ){
$aPor = (int) get_post_meta( $a, 'photo_order', true );
$bPor = (int) get_post_meta( $b, 'photo_order', true );
if ( $aPor === $bPor ) {
return 0;
}
return ( $aPor < $bPor ) ? -1 : 1;
} );
foreach ($vid_pix as $vP) {
// echo `div.photo-upload-box` here
}
}
?>
</div>