Hi - I am working on an 'Artwork Info' meta box created with the WPAlchemy MetaBox PHP Class. In my child theme's functions.php I am using the following to loop through and print the field values:
// Print the meta box data - called in display_artwork_info()
function print_meta($val){
global $artworkinfo_metabox;
if($val != '') {
$artworkinfo_metabox->the_value($val);
echo "br";
}
}
// Display Artwork Info fields in post
function display_artwork_info() {
global $artworkinfo_metabox;
global $post;
global $terms;
$values = array('title','collabs','dimen','additional');
$artworkinfo_metabox->the_meta();
echo the_content();
echo '<div id="artwork-meta">';
// Loop through the meta values
foreach ($values as $val){
print_meta($val);
}
echo '</div>';
}
add_action('thematic_post', 'display_artwork_info');
This all works well, except if one or all of the fields are empty, the line breaks still echo. With one field missing, the HTML comes out like this:
<div id="artwork-meta">
Title
br <!-- no value but break still echoes -->
br
Dimensions
br
Additional Info
br <!-- also shouldn't be there... -->
</div>
Any ideas? Thanks in advance.
P.S. I'm writing br instead of the actual tag because the forum applies it as a tag.