Support

Account

Home Forums General Issues Unwanted Commas on Frontend

Solved

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?

  • probably added by code that you use to display the images

  • 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.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Unwanted Commas on Frontend’ is closed to new replies.