Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
Not sure that you can do this. Shortcodes have to be in a page or post, don't they. I don't think you can put a shortcode between form elements. Where would you put them? ... in the contact form 7 settings? You cant do that there AFAIK ( unless you're following some contact form 7 instructions I haven't heard of). –  byronyasgur Mar 12 '12 at 12:59
add comment

1 Answer 1

up vote 9 down vote accepted

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><!-- 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!

share|improve this answer
Actually - you can add the filter code in your theme's functions.php and shortcodes will work properly inside a CF7 form. I can't confirm whether the specific one(for the accordion) will work or not though - I've only tested with a shortcode that doesn't contain any CF7 shortcodes, but basically it all depends on how the shortcode in question is handled. –  Nikola Ivanov Nikolov Mar 20 '13 at 12:35
indeed, a simple add_filter( 'wpcf7_form_elements', 'do_shortcode' ); does the trick from my child theme's functions.php. –  Evan Mattson Sep 30 '13 at 3:21
Thanks @EvanMattson that worked perfectly! –  DACrosby Dec 10 '13 at 19:42
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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