Support

Account

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

Unread

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.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.