Support

Account

Home Forums Front-end Issues I can't echo acf textarea in javascript

Solving

I can't echo acf textarea in javascript

  • I could extract text field, select field…

    But textarea does not extract by this way, it just show blank or error

        var product_advantage = "<?php echo the_field('product_advantage', 'user_1') ?>";
        alert(product_advantage);

    The same error if I do with shortcode functions
    It seems not able to show with “user parameter” in textarea?

  • echo the_field() is incorrect. Use either echo get_field() or the_field()

  • The same for these:

      echo the_field()
      echo get_field()
      the_field()

    I’m ok with “text” field, and “textarea” field with 1 row
    But when “textarea” field have 2 rows and more, it’s failed

  • the_field() echos, so you don’t need echo with the_field()

    If other fields are working then a textarea field should be working. It come down to what is being echoed. What value is actually output to the page? Is there something in the value that could cause an error? Can you actually do what you are attempting to do? What value are you attempting to echo? What is the value of the field?

  • I ‘ve done it

    You must use Template literals syntax for multi rows in text area. This will solve exactly this.

    Just change like this

    https://tinyurl.com/y5dr6xc9

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

You must be logged in to reply to this topic.