styling the_meta()
-
Hello,
I’m trying to learn how things work in WP and got stumbled on this one.You see, I’m trying to stylize my wp theme especially on its custom fields. this is what i did:
<div class="cfield"> <?php the_meta(); ?> </div>
obviously it worked just fine whenever a user fill the custom field (or when an admin create a new key+value). but what i don’t know is when a user did not fill any custom fields, you’ll see a blank ‘box’ in the template. the blank ‘box’ that was created by the <div class=”cfield”> is still there without anything inside it (of course).
is there a way to make the <div class=”cfield”> (and other related styling) hidden when a user left the custom fields blank?
do i have to edit this (post-template.php)?
function the_meta() { if ( $keys = get_post_custom_keys() ) { echo "<ul class='post-meta'>\n"; foreach ( (array) $keys as $key ) { $keyt = trim($key); if ( is_protected_meta( $keyt, 'post' ) ) continue; $values = array_map('trim', get_post_custom_values($key)); $value = implode($values,', '); echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value); } echo "</ul>\n"; } }
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘styling the_meta()’ is closed to new replies.