Support

Account

Home Forums Front-end Issues Show ACF in shortcode without a linebreak

Unread

Show ACF in shortcode without a linebreak

  • This seems like it should be easy, but I’ve tried all the tips I found, and they don’t work.

    In Visual Composer, I have a row (in an accordion) Text element, followed by ACF with the numeric value I want to display. I’d like to put the units of that number (in., cm, whatever) after the number rather than in the text element to the left. I thought there was a “suffix” function in the ACF, but that’s only for the input? Whatever. So I thought I’ll just put the ACF shortcode in a text field, followed by the string I want, like “in.” The field displays the number just fine, but “in.” is always on the next line. I tried a raw html element. Same thing. The shortcode is putting in the line break. How do we turn that behavior off?

    I found tips that said to put these lines in my functions.php, but they don’t help. How can this not be a common thing for people to do? I can add a third element in the row and put the “in.” in there to be in line, but there’s a huge space, and I want to do this with every field. Please tell me I’m missing some bleeding obvious check box somewhere. Thank you.

    Code that doesn’t help:
    remove_filter( ‘the_content’, ‘wpautop’ );
    add_filter( ‘the_content’, ‘wpautop’ , 99 );
    add_filter( ‘the_content’, ‘shortcode_unautop’, 100 );

    function removebreaks($content)
    {
    $content = str_replace(‘<br>’, ”, $content);
    $content = str_replace(‘<br/>’, ”, $content);
    $content = str_replace(‘<br />’, ”, $content);
    $content = str_replace(‘<BR>’, ”, $content);
    $content = str_replace(‘<BR/>’, ”, $content);
    $content = str_replace(‘<BR />’, ”, $content);

    return $content;
    }
    add_filter(‘acf_the_content’, ‘removebreaks’);

Viewing 1 post (of 1 total)

The topic ‘Show ACF in shortcode without a linebreak’ is closed to new replies.