Is there a way to return single values only when I run
get_post_custom($post_id);
it seems that I’m receiving double array, even when there only one value for this meta_key
Is there a way to return single values only when I run
get_post_custom($post_id);
it seems that I’m receiving double array, even when there only one value for this meta_key
this is what I’ve done to achieve this, it will return single dimension array when single results are found, and bi-dimensional array when multiple results are found
/*
* Get post custom Single (in functions.php)
*/
function get_post_custom_single($post_id) {
$metas = get_post_custom($post_id);
foreach($metas as $key => $value) {
if(sizeof($value) == 1) {
$metas[$key] = $value[0];
}
}
return $metas;
}