Thread Starter
Drding
(@drding)
Sure, is there a place I can email a link to you? It’s currently on a private server as it’s still a WIP, and I’d like to not post a link to it here.
Thread Starter
Drding
(@drding)
@takayukister
I’ve done a little debugging and I think, my issue might be how I’m calling to the contact form.
At first I was placing the short code in a post and then calling to that post in my template via:
<?php
$my_postid = 8;//This is page id or post id
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
?>
Next I tried just calling to the form’s short code directly in the template with:
<?php echo do_shortcode('[contact-form-7 id="5" title="Application Form"]'); ?>
With both of those, the counter is not working. So I guess the question is, what’s the best way to call to the form in a template? I’d like to have the form on my main index page (it’s a one page website) and not on its own page. Any advice?
Check to see if Contact Form 7’s scripts.js file is loaded on the page.
what’s the best way to call to the form in a template?
See FAQ > Can I embed a contact form into my template file?
Thread Starter
Drding
(@drding)
You know what, the js file isn’t loading. Even when I’m calling to the form via do_shortcode. The form itself is loading and I can fill it out and receive the form data in an email.
That is really weird. I mean I could just put a link to the js file in my header.php, but I wonder why it’s not being loaded in there automatically. I’ve used CF7 before on other themes I’ve built.
Do you know offhand what might be causing it not to load in? The theme itself is pretty basic, not a lot to it. CF7 is actually the only plugin I have installed.
Thread Starter
Drding
(@drding)
Small update, I added <?php wp_footer(); ?> to my footer.php thinking it was that, but no luck. While I do see some of wordpress’s main .js files loading now down there, CF7’s is still not.
Thread Starter
Drding
(@drding)
Got it! I took another look over your troubleshooting/FAQ and discovered I was missing <?php wp_head(); ?> before my closing head tag. After adding that the .js loads and the character display is counting down.
So if anyone else is coding their own theme and having this issue double check that you have <?php wp_head(); ?> before your </head> along with a link to the latest jQuery library in your header.php file. And also have <?php wp_footer(); ?> after your </html> in your footer.php
And just for the sake of reference (in my case) I’m including my form via a short code IN my theme like this:
<?php echo do_shortcode( '[contact-form-7 id="8" title="Application Form"]' ); ?>
Your form id number and title are going to be different of course, but that’s the call to it.
Thanks for all your help @takayukister!!