Remove P Tags From Easy Content Types Text Area

When using Easy Content Types plugin to embed videos, a P tag is generated and placed around the iFrame. For one reason or another, using any of the standard P tag removal methods did not work to remove this particular P tag. Forutunately, Pippin Williamson was kind enough to provide me with this filter, which solved the problem.

1
2
3
4
5
//get rid of P tags from ECPT plugin
function pw_filter_textarea($value){
return $value;
}
add_filter( 'ecpt_textarea', 'pw_filter_textarea' );

Other P Tag Removal Snippets

These work in different cases. Try them out in your functions.php file and see if they solve the issue for you.

1
2
3
4
5
6
//filter the <p> tags from the images and iFrame
function filter_ptags($content)
   {
      $content = preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); return preg_replace('/<p>\s*(<iframe .*>*.<\/iframe>)\s*<\/p>/iU', '\1', $content);
   }
add_filter('the_content', 'filter_ptags');
1
2
3
// Remove automatic paragraphs
//remove_filter( 'the_content', 'wpautop' );
//remove_filter( 'the_excerpt', 'wpautop' );
1
add_filter( 'ecpt_textarea', 'sanitize_text_field' ); // first attempy from pippin - didn't work.