Definite solution: Seeing as wp’s core get_post_custom function returns multiple data fields saved as a single key in a random order, I resolved the issue by writing a function to replace it – which has some added flexibility:
/*---------------------------------------------------------------
Function: Retrieve post meta field for a post based on ID
Usage: [admin/meta_box/downloads.php] = to replace core wp get_post_custom function
Params: $id = post id, $key = meta key, $order = ASC|DESC,
$return = meta_value|meta_key|post_id|meta_id, $single = true|false
@return = result will be array unless $single = true, which will return the last result only
----------------------------------------------------------------*/
function noconflict_get_post_custom($id,$key,$single=false,$column='meta_value',$order="ASC"){
global $wpdb;
$data = $wpdb->get_results("
SELECT * FROM $wpdb->postmeta WHERE post_id = $id
AND meta_key LIKE '$key'
ORDER by meta_id $order
");
if( !empty( $data ) ) {
$metadata = array();
foreach( $data as $result_object ) {
$metadata[] = $result_object->$column;
}
if ($single)
return $metadata[0];
else
return $metadata;
}
}