Support

Account

Home › Forums › General Issues › Replace Comma With Line Break On Select Field Type When Using ACF Shortcode

Solving

Replace Comma With Line Break On Select Field Type When Using ACF Shortcode

  • Hi there,
    Programming noob here. I use ACF on my website to display affiliate links to products on Amazon. I achieve this by using a “select” field type with the return format set to “both (array)”. The “value” is the Amazon SiteStripe image code and the “label” is a short product description. I implement this on my Elementor page builder using the acf shortcode [acf field="field_name"], since Elementor’s dynamic tags doesn’t seem to work properly with select field types.

    Overall I am happy with how it looks, but I would like to remove the comma “, ” that seaparates the value and the label on the frontend and replace it with a line break <br>.

    I searched around your forum before posting this and interestingly enough, I found a post extremely similar to mine, located here: https://support.advancedcustomfields.com/forums/topic/checkbox-field-commas-shortcode-for-get_field/

    I tried implementing the code snippet posted there into my functions.php, but when I visited my site I was met with a “There has been a critical error on your website” message.

    Like the other person in the above post, my knowledge of php is very limited, so I wondered if someone could be so kind as to provide me with a code that I can also add to my functions.php file that would allow me to achieve the desired line break in place of the comma?

    Many thanks.
    Tom

  • There isn’t any way to alter the way that ACF works when using shortcodes unless you add code to your theme. For something like this you could use https://www.advancedcustomfields.com/resources/acf-format_value/

  • Thanks for the reply and pointing my in the right direction.

    As I mentioned above though, I lack programming knowledge, so I’ll just have to pay someone to come up with the solution.

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

The topic ‘Replace Comma With Line Break On Select Field Type When Using ACF Shortcode’ is closed to new replies.