I’m trying to set this up so that the form slides out when a phrase (eg “Use this contact form to reach us”) is clicked.
I’m using the Hackadelic Sliding Notes plugin for this sliding effect. But the code ([contact-form to=”email@example.com”] does not execute … it’s just written out in text.
Looking at the syntax you have there, I assume you’re using ‘Contact Form 7’. But are you trying to include the form directly in a template file, under the HTML tag in WP, or straight in the page editor?
Also, why are you storing your email address there? A better way is to set that up in the plugin settings and use the form name instead:
[contact-form 1 "Contact form 1"]
Now, to include it directly in a template file (or under the HTML tab in the page editor), use the do_shortcode function (source):
<?php echo do_shortcode( '[contact-form 1 "Contact form 1"]' ); ?>
Unless I’ve missed something, that should fix it for you.
Thanks for your response. I had forgotten about this post.
I use Grunion Contact Form in conjunction with Hackadelic Sliding Notes.
As it turned out, HSN does accommodate shortcodes within its shortcode. I just didn’t know this at the time that I posted here three months ago.
Ah.. Ok, I see. The shortcode for Grunion looks pretty similar to CF7 then…
Well, I could help you find an alternative layout if you like, but I get the impression you’ve already moved on to other things. 🙂
I was considering to use template code and to set it up so that, if possible, (1) individual email addresses are used and also (2) the form is displayed like an image using color box frame and when a phrase (eg “Use this contact form to reach us”) is clicked.
However, could this following code be used for individual emails?
<?php echo do_shortcode( '[contact-form to="<?php echo get_post_meta($post->ID, 'my_email',true);?>"]' ); ?>
Moreover, what should I add more to make it to be displayed through colorbox frame?
I’m not sure what you mean by “individual email addresses”, do you mean a single contact form that can send to different a email address depending on the options selected?
If so, you can create your own fields easily with Contact Form 7, one of which is a drop-down list. Using that you can assign different email addresses depending on the option selected in that list.
After that, it’s simply a case of inserting that into a theme wherever you want it to be. How and where is entirely up to you, everybody has different methods they prefer, at the end of the day it depends on how flexible you need that area of the site to be.
Thanks for a fast reply.
No, that was not what I meant.
I have provided a custom field called my_email for each post. It is intended that if any author wants to attach a contact form to the post, he/she may only type an email address in this field which will allow the the form to be displayed in the bottom of the post when it’s published, and the response will be sent to the email address (or addresses) typed in the custom field.
However, the main issue is to make the form be able to chose the value of the custom field. Accordingly, empty field means no form to be displayed.
I’m not sure I follow the reasoning behind it, but from the mechanics point of view, I think you’ll need to use a bit of jQuery to achieve this. Perhaps an input field with the post method that passes the entered email address into a jQuery function and saves it as a variable, from there you should be able to pass that variable into a contact form and display it.
Just thinking about it now, you might want to post a new question for this; you’ll probably have a better chance of finding an answer that way.
Overwise, you could even ask for some ideas over at WebDesignerForum, it sounds like your idea goes into areas other than simply WordPress with plugins.
- The topic ‘Form in slider’ is closed to new replies.