I’m using Advanced Custom Fields’ flexible content area in a WordPress theme that I’m developing. One of my sub_field
s requires a textarea
.
When I make my get_sub_field
call from my template it is already wrapped in <p></p>
tags. How do I go about adding a class to that paragraph?
Example:
get_sub_field('textarea');
Output:
<p>This is my textarea.</p>
Desired:
<p class="my-class">This is my textarea.</p>
Thanks for your help!
Go to your Textarea custom field settings and change “Automatically add paragraphs” to none.
So WP-admin-> Custom Fields -> Field group -> then your field group-> edit textarea-> look for “Controls how new lines are rendered”
You can add a second
false
argument toget_sub_field()
to disable reformatting on a case-by-case basis in the template: