Leave a Reply

1 comment

  1. use php’s implode to join array elements with a string:

    <?php
    if( $bands = get_post_meta($post->ID, 'band') ):
        ?>
        <strong>Band:</strong> <?php echo implode( $bands, ', ' ); ?><br />
        <?php
    endif;
    ?>
    

    EDIT- another version of above, pluralizing the label depending on single or multiple meta values:

    <?php
    if( $bands = get_post_meta($post->ID, 'band') ):
        $label = count( $bands ) > 1 ? 'Bands' : 'Band';
        ?>
        <strong><?php echo $label; ?>:</strong> <?php echo implode( $bands, ', ' ); ?><br />
        <?php
    endif;
    ?>