Home › Forums › General Issues › Unwanted Commas on Frontend
Hi. I’m hoping there’s a simple solution to this. Using ACF I have a list of required checkboxes in the post meta which chooses from a set of images to be displayed in the frontend. It works fine except that for each additional image selected to appear an extra comma appears at the end of the row of images.
Please see attached screenshot. These commas are being added dynamically and I’ve not accidentally included a comma in the ACF value to be displayed.
Does anyone know how to fix?
Thanks for the reply mediawerk but that’s not the case. Initially I had all the images display normally before making them optional using ACF. There were no commas then. The commas have appeared only since using ACF to display the images and I’ve checked all code and values for stray commas – there are none.
It seems to me as though ACF is more geared towards displaying text, and somehow separates each text value with a comma automatically. This is useful but not when the values are images rather than text.
Solved!
By referencing this page: http://www.advancedcustomfields.com/resources/checkbox/
I noticed the code for displaying multiple values on the frontend is:
<?php echo implode(‘, ‘, get_field(‘field_name’)); ?>
So simply by using this but removing the comma it displays the multiple selected values but without adding a comma between each.
<?php echo implode(‘ ‘, get_field(‘field_name’)); ?>
I hope this helps someone else!
for a next time:
with only a image for debug the problem it is nearly impossible to help.
without any code, fields you use … (maybe url to site) everything is only guessing.
The topic ‘Unwanted Commas on Frontend’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.