In Dr Reborn Revamp project, it is necessary to pass a data from one page to another page so as to display that data in a CF7 form.
The CF7 form page is called by a Call-to-Action button on every page. The approach is to pass the data as a query string through a URL in the CTA button. That CF7 page retrieves the data by the get_query_var() function and performs the necessary CSS hide and display. By using the plugin “contact-form-7-dynamic-text-extension”, a dynamic text field is created and get the passed-in data.
- In functions.php, register ‘cu_form_data’ as a query_var.
- Bottom Page Content widget:
- add a CTA button (1)
- href pointing to the page containing the CF7 form.
- Treatment single post
- add another CTA button (2)
- href pointing the page containing the form and passes the post title to the ‘cu_form_data’ url parameter.
- use CSS to hide button 1.
- Page containing the CF7 form
- this page uses a custome template derived from the full-width.php
- use get_query_var(‘cu_form_data’, defaultValue) to get the post title or defaultValue
- in the form, create a dynamic text field to display the post title
- if cu_form_data contains the default value, use CSS to hide the dynamic field, else, hide the select field.
