[Plugin:Contact Form 7] calling do_shortcode in template works sometimes
-
I have a template and want to use the
[contact-form-7 id="123" title="your title"]
shortcode. However, I want to pass in the actual shortcode, so I can display different tables dependent upon what is passed in. I have created a custom field for my post and have stored the shortcode in it.What works: In the template, if I assign the shortcode to a variable inline, the page will display the form.
<?php $cfsignupname='[contact-form-7 id="2995" title="Arnett Creek - Lower Picketpost Mesa (UI) - 60 Nov 2016"]'?> <?php echo do_shortcode($cfsignupname);?>
What doesn’t (and what I want to do):
In the template, get the shortcode field from the page’s custom fields, then call the shortcode.<?php $formshortcode=get_field("signup_cf7_shortcode");?> <?php echo do_shortcode($formshortcode);?>
This returns a [contact-form-7 404 “Not Found”]
If I echo out both the $cfsignupname and $formshortcode variables, they appear to be identical.
So, why would the inline hardcode ver work, and the get_field ver return the 404 error?
- The topic ‘[Plugin:Contact Form 7] calling do_shortcode in template works sometimes’ is closed to new replies.