Support

Account

Home Forums General Issues Acf is adding line breaks an paragraphs in Shortcode output code

Solving

Acf is adding line breaks an paragraphs in Shortcode output code

    • dsnger

    • June 28, 2020 at 7:47 pm

    Hello guys, I have a problem with unwanted <br /> and p-tags in the shortcode output only if it comes from an ACF field and output code, for example in the shortcodes from Wpforo (forum) or Ultimate Member used in an ACF WYSIWYG field.

    Once I solved that, but unfortunately forgot how and cant find it. It had nothing to do with wpautop or anything like that. I don’t want cut them out, i want prevent them.
    Can someone help me and has the solution ready? I’ve googled myself sore! I am very happy …Thanks a lot

  • I just did a quick test of a shortcode in both classic editor and an acf WYSIWYG editor. This shortcode simply outputs simple text. The output is the same in both cases with no added whites space elements added to the text.

    Exactly what/how are you adding with the shortcode?

    • dsnger

    • June 29, 2020 at 5:40 pm

    Hello John, thanks for your answer.
    I have no problems with my own shortcodes or shortcodes in general, but only if the shortcode comes from a plugin and outputs a code template will I get these unwanted line breaks. For example with Ulitmate Member Plugin, WPForo or finally I tried to use the email download link plugin (https://de.wordpress.org/plugins/email-download-link/).
    My template is entirely based on ACF. All fields of my template are saved in an array. Instead of the expression “the_field (‘prefixed_field_name’)” I use “echo $ field_output (‘field_name’)”, because I remove the prefix beforehand.

  • If you’re not using acf function to get field values, how are the_content filters being applied? Is shortcode_unautop() being applied in the correct place?

    • dsnger

    • June 29, 2020 at 10:07 pm

    I think i do nothing special. I get the value from a field with the regular get_sub_field() function from a repeater. Than I store it into an array.

    $field_value = get_sub_field($field_name);
    //cut out module name to get pure field name
    $field_name = str_replace($mod_name . ‘_’, ”, $field_name);

    $field_output[$field_name] = $field_value;

  • I’ve tried this with other plugins that add shortcodes and I’m not seeing any issue. The plugins you mentioned would be too involved to me to set up and test on one of my test sites and your setup seems complex.

    Can you give me an example of shortcodes in a WYSYWIG that is producing the extra white space?

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.