Support

Account

Home Forums General Issues disable wpautop for CF7 shortcode

Helping

disable wpautop for CF7 shortcode

  • My shortcode [contact-form] renders a form („Contact Form 7“). 
    I disabled WPAUTOP and it works in ‘the_content’, but not in an ACF custom field (WYSIWYG). It adds empty p-tags.

    My code:

    
    // shortcode
    function my_form_shortcode($atts) {
      ob_start();
      $content = do_shortcode('[contact-form-7 id="377"]');
      return $content;
    }
    add_shortcode('contact-form', 'my_form_shortcode');
    

    I disabled wpautop for CF7 with:

    
    add_filter('wpcf7_autop_or_not', '__return_false');
    

    and in wp-config.php with:

    
    define('WPCF7_AUTOP', false);
    

    How can I disable wpautop for this shortcode to work also in custom fields?

  • Why are you adding your own shortcode to do a contact form 7 shortcode? Why not just insert the CF7 shortcode into the editor?

    For whatever reason your shortcode is being run before autop is run. In ACF just like WP shortcodes are run last so under normal conditions autop should not be applied to the form.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.