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
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Max length of meta_value
- How to get custom post meta using REST API
- The “_encloseme” Meta-Key Conundrum
- Using get_post_meta with new_to_publish
- SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
- Can I count the number of users matching a value in a multiple value key?
- Auto sort the wp-admin post list by a meta key
- WP doesn’t show Array Custom Fields?
- Allow user to create instances of custom field
- How do I search an array stored in a custom-field using WP_Query?
- get_pages sort alphabetically by meta value
- Get updated meta data after save_post hook
- Save HTML formatted data to post meta using add_post_meta()
- ajax delete value from custom field array
- Save attachment custom fields on front end
- Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta
- Unable to show ACF’s Image Custom Field properly in Genesis Framework [closed]
- Custom field value based on other custom field values
- Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
- How to display Meta Field Value?
- Combine multiple custom field values into single value
- How do I use wp_query for WordPress search?
- Nav Menu – Add class based on meta keys
- Can’t get post ID using wp_insert_post_data
- Unique Post Meta Values
- Add post meta fields, when creating a post using WordPress’ REST API
- Store array as single, serialized post meta field or many post meta fields?
- Custom Field Values not updating unless I click “Update” twice
- update_post_meta for repeated custom field [closed]
- Removing link ” from ” on meta_value in custom feilds
- Trying to update_post_meta function
- get_posts in meta box dropdown not showing latest posts
- Ordering posts by custom field named “date” in backend
- Unique meta_key with array value vs repeated meta_key with single values
- Allow only one post with specific meta value
- How to validate select field in post meta?
- How to display childrens custom fields?
- how to display custom fields of post on a web page
- How do I query the title (or handle?) of post meta fieldset (created with Simple Fields Plugin)
- How to fill custom fields with brackets in their key with add_post_meta()?
- how can I show name and value of Custom Fields together?
- Gravity Forms Update post meta from template [closed]
- put saved metabox values back into fields and then display on the front end
- How to get custom image field of specific post id
- Custom field to array?
- wordpress multi user question
- Working with multiple values and metaboxes
- How to change text color depending on the number value (Using javascript)
- How can I change author of posts to the value of one of the custom field of the posts?
- get posts based on non-single metadata
- Adding Custom Metadata to my Archive/Posts page
- How to improve my non-unique metadata MySQL entries?
- Saving Custom Field that includes Quotation marks
- Custom Fields Not Showing (ACF not installed)
- Post meta data not showing in frontend, until hitting ‘update’ button
- searching by keywords in post’s metas or pagination links problem
- Add custom field information to source meta data
- How do I update custom field post meta in frontend post template?
- How to Find List of Available Custom Fields for Theme?
- Create Shortcode shows only posts with custom_field meta
- update meta field value after
- Custom Fields Not Working In Footer
- ACF plugin and field update
- Plugin Shortcode value in post
- Echo out custom fields in comments
- Search one custom field?
- Can’t save meta field value if the title not set
- Display Data From This Custom Media Upload Meta Box?
- Save values generated via API as custom meta fields
- Sorting Posts with meta value not working
- Adding custom fields to images
- How to save dynamically generated value in post type?
- update_post_meta not working in action hook
- how to show this part only in the single post page?
- Display meta data from a custom field within plugin Category Grid View Gallery
- If post custom meta data is not set, show normal state
- Display a list of posts whose meta field values are equal to the ID of the post being viewed?
- custom field with links
- add multiple values (array) to post meta_input
- Check for custom field value in different post type than current one and do something
- save all acf options in one meta_value [closed]