Home Forums Front-end Issues Issue with Text Area in a Group field


Issue with Text Area in a Group field

  • Hi everyone,
    I have noticed an issue using a Text Area with auto <br> in a group field.
    By doing this, the <br> tag appear as a plain text, not as a HTML tag.

    Here is the code I am using:

    $titraille = get_field('titraille');
    if( $titraille ): ?>
        <div class="center">
            <p class="sur_titre">
                <?php echo esc_attr( $titraille['sur_titre'] ); ?>
            </p><!--  .sur_titre -->
                <?php echo esc_attr( $titraille['titre'] ); ?>
                <?php echo esc_attr( $titraille['test_titre'] ); ?>
        </div><!--  .center -->
    <?php endif; ?>
  • This is because you are using esc_attr() on the value. ACF is adding the <br> tags and you are converting the < and > into html entities by using this function.

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

You must be logged in to reply to this topic.