• Resolved scamrwordpressadmin

    (@scamrwordpressadmin)


    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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter scamrwordpressadmin

    (@scamrwordpressadmin)

    Note: I also need to call the shortcode [cfdb-table ….] and pass in variables…. I’m getting the same results as above, with one exception.

    If I refresh the page a second time – the table will display.
    Refresh a third time – it goes away.
    Refresh a fourth time – it comes back.

    Every other refresh it works. hmmm….

    Thread Starter scamrwordpressadmin

    (@scamrwordpressadmin)

    I tested this with other themes…
    The initial [contact-form-7 id=”123″ title=”your title”] shortcode call behaves as in the first post (only works if variable assigned inline, vs using get_field)

    However, the shortcode for [cfdb-table….] works the first time in other themes, vs only working on every second page refresh.

    Thread Starter scamrwordpressadmin

    (@scamrwordpressadmin)

    As noted above, I installed a different theme to test the shortcode calls, and they worked fine in other themes. Then, I went back and activated the Minamaze_Pro-child theme that I had. And CRASH! The system threw fatal errors and I couldn’t get in to even swap that them out for say Twenty-Fifteen. My hosting company put back Twenty-Fifteen for me so I was up and running.

    In the end, I deleted the child theme and recreated it from scratch. (Thank goodness for file backups). I restored the child theme files and am back up and running.

    The short code calls now work the first time, and every time.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin:Contact Form 7] calling do_shortcode in template works sometimes’ is closed to new replies.