The Contact Form 7 WordPress plugin is a very powerful plugin that we typically use on any WordPress development project that requires forms. Often times we run into situations where we need to dynamically add a WordPress post title in either the subject line or email body generated by the form. Luckily, this situation is very easy to handle with the aid of an extension plugin. In this tutorial we will teach you how to dynamically add a WordPress post title in the Contact Form 7 plugin.
Step 1: Install the Contact Form 7 Dynamic Text Extension Plugin
In the first step of this tutorial we will need to install the ‘Contact Form 7 Dynamic Text Extension Plugin’ from the WordPress plugin directory. This plugin will allow the ability to add dynamic content capabilities to the ‘Contact Form 7 Plugin’.
Items to Note:
- Make sure that you also have the ‘Contact Form 7 Plugin’ installed.
- This is a very powerful plugin and dynamically adding the WordPress post title is just one of its many capabilities.
Step 2: Generate the Hidden Dynamic Content Tag in Contact Form 7
In the next step of this tutorial we will generate the hidden dynamic content tag that will be used to dynamically add the WordPress post title in ‘Contact Form 7’.
While in the WordPress Dashboard go to the ‘Contact Form 7’ settings page and make sure you are viewing the tab ‘Form’. Copy and paste the form-tag code below then add it inside the form code block; refer to ‘Items to Note’ for a breakdown of the form-tag.
Contact Form 7 – Form-Tag Code[dynamichidden chapter "CF7_get_post_var key='title'"]
Items to Note:
- The item ‘dynamichidden’ is the form-tag name, DO NOT change this, this is how ‘Contact Form 7’ knows what type of tag this is.
- The item ‘title’ is the unique name given to specify the form-tag as a variable; you can change this to whatever you like.
- The item “CF7_get_post_var key=’title'” is the shortcode used to get the WordPress post title, DO NOT change this.
Step 3: Displaying the Hidden Dynamic Content Tag Variable in Contact Form 7
In the final step of this tutorial we will display the hidden dynamic content tag variable in ‘Contact Form 7’.
While still on the ‘Contact Form 7’ settings page, click on the tab ‘Email’. You can now use the variable code tag below to display the WordPress post title in either the ‘Subject’ or ‘Message Body’ of ‘Contact Form 7’.
Contact Form 7 – Variable Code[title]
Items to Note:
- If you changed the unique name in Step 2, make sure that you are using the correct variable tag.
If you are having problems getting this tutorial to work please reread the tutorial and try again, if you still cannot get it to work please leave us a comment below and we will respond as soon as possible. Please do not email us with problems regarding this tutorial, only comments will be responded to.