Support

Account

Home Forums Front-end Issues ACF Multi-Select Field Outputs a Random Comma

Helping

ACF Multi-Select Field Outputs a Random Comma

  • Hi,

    Using the following code from the ACF Select page (https://www.advancedcustomfields.com/resources/select/);

    
    <?php
    $colors = get_field( 'color' );
    
    // Create a comma-separated list from selected values.
    if( $colors ): ?>
    <p>Color: <?php echo implode( ', ', $colors ); ?></p>
    <?php endif; ?>
    

    Why am I getting a comma if there is only one option selected?

    I had imagined it would only show commas to seprate options.

  • It should not be displaying the comma if the array only has a single value.

    Is the code in the OP the actual code used or is this just copied from the link you provided?

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

You must be logged in to reply to this topic.