Hiding empty custom fields
-
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.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Hiding empty custom fields’ is closed to new replies.