I noticed that any shortcode that is not part of the contact form 7 builtin shortcodes dont work.

For example: I am trying to use an accordion shortcode between form elements in contact form 7. But the code dont work.

How to solve this without editing contact form 7 core files?

1

There’s two ways to do what you’re wanting. First way is to add this code to functions.php of the Contact Form 7 plugin:

add_filter( 'wpcf7_form_elements', 'mycustom_wpcf7_form_elements' );

function mycustom_wpcf7_form_elements( $form ) {
$form = do_shortcode( $form );

return $form;
}

That allows you to drop shortcodes directly into CF7. Second is to add the Accordion in manually with HTML in the contact form, like this:

<!-- begin class .wp-accordion -->
<div class="wp-accordion wpui-light">

    <!-- First tab's panel -->
    <h3 class="wp-tab-title">Tab 1</h3>
    <!-- First tab's contents -->
    <div class="wp-tab-content">
          All the contents of first tab goes here....
    </div><!-- end first tab -->

      <!-- Like so, Second panel -->
      <h3 class="wp-tab-title">Tab 2</h3>
      <div class="wp-tab-content">
            Contents of the second tab
       </div>

</div><!-- end class wp-accordion -->

I think the second method is preferable, since there is no modifying of core plugin files. I hope this helps out!

Leave a Reply

Your email address will not be published. Required fields are marked *