Quick Hack to Remove Auto ‘P’ Tag from Contact Form 7

Recently I had a situation where I needed to remove the auto generated ‘p’ tag from Contact Form 7, but could not do it in the conventional way. Contact Form 7 uses a number of constants, set in the WP config file, which allow behaviour changes. I always found that a bit of an odd approach (configuring a plugin’s options from the entire site’s config file), but it generally caused little concern. On this project, however, it was not possible since the site lives on a multisite install and only one theme required the change.

Surprisingly, I found no other filter options that could be accessed easily. I’m sure it can be done, but in the time I had I didn’t find anything. So the quick and dirty answer was to write a jQuery hack that can simply remove the ‘p’ tag for this one site. Here it is:

jQuery(document).ready(function ($) {

$(".wpcf7-form").find("p").contents().unwrap();

});

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>