How to show checkbox fields as comma-separated instead of a bullet list
By default, checkbox fields are displayed as a bulleted list. If you want to display them as a list of comma-separated values (CSV), you can do that with GravityView and a little code.
Before and After
This is the default look for checkbox fields:
And this is how the field values look once converted to CSV.
The required code
/** * Convert checkbox <ul> to CSV values * * @param string $output The current output. * @param \GV\Template_Context The template context this is being called from. */ add_filter( 'gravityview/template/field/checkbox/output', function( $output, $context ) { $value = $context->value; // If a checkbox value is '' (empty string), this removes it. If you want empty strings, remove the line below. $value = array_filter( $value, 'gravityview_is_not_empty_string' ); return implode( ', ', $value ); }, 10, 2 );
Read here how to add these code samples to your website: Where to put code samples.