I have defined a custom post type, and with it, a number of custom fields that are displayed. All is well, except, I cannot hide fields, when they are not filled in. This is how I tried to do it:
function the_brb_meta() {
global $id;
if ( $keys = get_post_custom_keys() ) {
foreach ( $keys as $key ) {
$keyt = trim($key);
if ( '_' == $keyt{0} )
continue;
echo "<ul class=\"post-meta\">\n";
$values = array_map('trim', get_post_custom_values($key));
$value = implode($values,', ');
if(!empty($key)) {
echo "<li><span class=\"post-meta-key\">$key:</span> $value</li>\n";
echo "</ul>\n";
}
}
}
}
but the empty fields still show up. What is wrong with my code's logic?
Any help appreciated.