i want to remove those <p> and <br/> tags from my contactform7 forms. now they have this wpcf7_autop which can be set to false when inserting:

define('WPCF7_AUTOP', false);

to wp-config.php

The problem is: I need this setting to be attached with my theme, so is it possible to some how do it through the functions.php file?

  • Plugin loaded before theme. It isn't possible! – Sumit Apr 4 '16 at 7:18
  • so how come i'm able to disable the plugins css and javascript from loading through the functions.php ? – Ben Apr 4 '16 at 7:23
  • CSS, JS are hooked on wp_enqueue_scripts which you can remove. But it is PHP constant. How about defining DB details in functions.php sounds wired right ? :D – Sumit Apr 4 '16 at 7:37
  • You can try minify html from the contact form 7

  • To completely disable the wpautop filter, you can use:

    remove_filter('the_content', 'wpautop');

If you have already upgraded CF7 to version 5.0 or higher, then you can use the new hook:

add_filter( 'wpcf7_autop_or_not', '__return_false' );

Use the following code to get ride of autop (automatic <p> tag) and line breaking tag (<br> tag).

// Remove auto p from Contact Form 7 shortcode output
add_filter('wpcf7_autop_or_not', 'wpcf7_autop_return_false');
function wpcf7_autop_return_false() {
    return false;

Add this code to your theme's function.php file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.