This topic contains 5 replies, has 2 voices, and was last updated by  Hans (Support Admin) 2 months, 1 week ago.

Contact Form 7 Shortcode in Header – Integral Theme

  • A complete novice here. I’m trying to add a contact form 7 shortcode into the header section (under the title) of the Integral theme.

    The ideal place would be the tagline in the ‘hero’ section. Simply adding in the shortcode to the (html allowed) tagline box in the customisation section just shows up as code and doesn’t display the contact form. I’ve also tried adding the shortcode into a post (where it works), then grabbing all the html and adding that into the same tagline box. This displays the form fine, but a long story short I’m trying to use multi-step/pages functions with the contact form and whilst they work on the post, the submit button won’t then work on the homepage header where I need it to work!

    I’ve attempted adding in php do shortcode into the ‘hero’ php file and tried allow shortcode into theme funtions, nothing seems to work. Could someone please give some advice on how to make the form 7 shortcode work in the header and ideally the tagline box?

    Hero php tagline:

    <?php if ($integral[‘hero-tagline’]) { ?>
    <div class=”lead text-center”>
    <p><?php echo str_replace(“\n”, “<br>”, $integral[‘hero-tagline’]); ?></p>
    </div>

    Many thanks, James

    Hello James,

    Use the following shortcode code,

    https://contactform7.com/faq/can-i-embed-a-contact-form-into-my-template-file/

    And replace this code,

    < ?php echo str_replace(\n,
    , $integral[‘hero-tagline’]); ?>

    With the shortcode code.

    That should do it.

    Hi Hans,

    Thank you for the advice. Unfortunately it still refuses to display. I changed both the child and parent themes’ code but nothing. I’ve tried placing that same php code in several places but the form just won’t show unless it’s a page or post. Strange one. James

    Hi James,

    Apologies for the late reply.

    That is strange. You did add it to the files for the parent theme correct?

    Can you provide me with admin access to your site so I can log in and have a look?

    Thanks.

    Hi Hans,

    Likewise apologies for the slow reply. Having read your last message I deleted the child file as well as some other bits I added but it still wouldn’t work in the tagline. Instead I created a new <div> in a space above which seems to have done the trick – I originally tried this but there must have been something clashing!? Anyway all’s fine now, the multistep function works a treat too thank fully.

    Thanks very much for the advice.

    James

    Hi James,

    Ahh great to hear you figured it out.

    Cheers,
    Hans

Tagged: 

You must be logged in to reply to this topic.