Home › Forums › Front-end Issues › Hide empty P tags generated by WYSIWYG › Reply To: Hide empty P tags generated by WYSIWYG
Thanks John – however, a detailed solution came through (which I think you were pointing me towards) from James on [email protected] which does exactly what I want. Code is (to put in [theme]/functions.php) :
function my_acf_load_value( $value, $post_id, $field ) {
$content = apply_filters('the_content',$value);
$content = force_balance_tags( $content );
$content = preg_replace( '#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content );
$content = preg_replace( '~\s?<p>(\s| )+</p>\s?~', '', $content );
return $content;
}
add_filter('acf/load_value/type=wysiwyg', 'my_acf_load_value', 10, 3);
No more empty <p> tags in ACF Wysisyg fields!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.