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;
?>
Related Posts:
- When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
- Is it possible to store arrays in a custom field?
- How to break meta values into different items and avoid duplicates?
- Get specific custom field keys from a post and put into an array
- How to wrap meta values seperated by comma in ? [closed]
- Sort alphabetically by custom field
- IF Custom field value equals ZERO
- Update post meta custom field using block editor
- change order of images attached to post
- query_posts with meta_value
- Show array of meta_value in Edit Post Coloum
- Set class if a meta value is set within post archive
- Custom Field: Display only if a specific key is selected outside the loop
- How do i output images from URL’s added to the same custom field key
- Build Array from Input Fields question
- WP Query Args – search by meta_key or title
- Saving multiple custom meta box fields
- get Custom field label (select/dropdown) on front end
- Block Editor – Meta values not saved, meta changes to empty array on update
- Custom post meta field effect on the performance on the post
- Difference between meta keys with _ and without _ [duplicate]
- Orderby meta_value only returns posts that have existing meta_key
- What is “meta_input” parameter in wp_insert_post() used for?
- How to enable revisions for post meta data?
- Can I query custom meta data through WP_Query
- How can I display all values of a custom field from posts with a certain value of another custom field or from certain post types?
- How do I search an array stored in a custom-field using WP_Query?
- Is there a hook / action that is triggered when adding or removing a post thumbnail?
- passing argument to get_template_part() or a better way to code
- Get updated meta data after save_post hook
- Order by custom field date with ASC order
- Create meta boxes that don’t show in custom fields
- Ordering posts by anniversary using only day and month
- use get_posts to get custom field data, but in one array
- How to use pagination with get_post_meta
- Copying Custom Meta Values from existing post to a duplicate post
- WP_query : meta_key with custom rule for specific value
- Move value of one custom field to another
- Displaying posts with only upcoming dates according their custom field date value
- Custom fields: In what order are they saved into the DB?
- Get a post_id where meta_value equals something in a serialized meta_value field
- How to save a ToggleControl value in a meta field?
- MySQL query to set wp_postmeta using term_taxonomy_id value
- How to Validate Post Meta type/extension (Video File Image File etc)
- Custom Meta Box not Saving in Posts with Gutenberg Editor
- How can I sort homepage by a meta value?
- How do I use wp_query for WordPress search?
- Nav Menu – Add class based on meta keys
- Passing Custom Field Data as Array to be Saved (Resulting Custom Field Array is inconsistent)
- Bulk remove post meta
- How to create html block to display extra information on woocommerce single product page
- How to create a Custom Meta Box with Name/Value Admin User Input Fields?
- Create Multiple File Upload Metabox in WordPress
- Create an Array of Specific Custom Post Meta
- Remove Body Classes
- WordPress Rest API to call page data associate with custom meta
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- Hide custom meta data if empty
- What WordPress function to use to get meta value by using meta keys?
- How to create a shortcode to print specific values stored in a post meta array?
- Add custom field to all posts in specific post_type
- Button inside Custom Meta Box triggering the Update Button
- How to load an assets based on custom field value?
- Custom WP_Query for WordPress Search Results with meta_query
- How can you include custom post meta in search without calling each key?
- Can I access a post meta field before the loop?
- wrap text around custom fields array
- How can I modify RSS item titles to be either the title or a custom meta field?
- Avoiding ACF get_field and returning to core WordPress function
- Get all the posts where meta field with multiple choice has several values checked
- Move Title and the Content WYSIWYG editor position
- List custom field values in alphabetical order without repetition
- How do i get the attached images with custom value checked?
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Print specific values stored in a post meta array
- Get custom fields without _edit_last, _edit_lock, _wp_page_template and _visual-subtitle
- Display posts with empty custom field
- Why am I getting a “Call to member function format() on a non-object” error?
- Modify custom field from front end
- Footnotes in custom fields
- Create a new custom field for all posts based on current custom field
- wordpress get_post_meta / the_meta to output custom field value
- How to Convert Custom Fields from Text to Array?
- Custom Query: query by post custom meta data
- Custom field outside the loop and inside an array
- update_post_meta not working well
- User query – getting values for custom meta keys/fields
- How to add a post’s view count into the WordPress API response
- Can’t set custom meta fields for a post
- Allow HTML in Custom Metabox area
- Custom field metabox not showing in back-end
- Query Multiple meta
- Query postmeta values, and return multiple post_titles for common meta value
- When post is updated, custom metadata in text area field is overwritten
- Media Attachment Custom Meta Fields not saving in Media Uploader when using jQuery UI Autocomplete
- When editing a post with a custom meta box the values aren’t displaying correctly
- add_post_meta insert null value into Database
- Retrieving custom field as shortcode
- Extract array from custom field
- save all acf options in one meta_value [closed]