How to remove wrapping p tags from acf wysiwyg field string for later custom excerpt processing How to remove wrapping p tags from acf wysiwyg field string for later custom excerpt processing wordpress wordpress

How to remove wrapping p tags from acf wysiwyg field string for later custom excerpt processing


I know this is old but maybe it helps someone else.

I had the same issue and using "false, false" as second and third parameter for get_field did the trick.

$myField = get_field('field_name', false, false);echo '<p class="custom-class">'.$myField.'</p>';


Maybe a simple string replace?

$text = get_field('title');$stripped_text = str_replace(array('<p>','</p>'),'',$text);


Another option is PHP's strip_tags function. This will remove all tags.

https://www.php.net/manual/en/function.strip-tags.php

$stripped_text = strip_tags( get_field( 'field_name' ) );