Hmmm, something is certainly strange going on with your form. The post id of the product is 260 but the hidden value of _wpcf7_container_post
is 0 when it too should be 260. That tells me right away the form is having trouble identifying the “current” post, so it makes sense why the shortcodes like CF7_get_current_var
and CF7_get_post_var
are returning unexpected values.
Typically, using this shortcode should be enough to display the current page’s title in a text field:
[dynamic_text product_name "CF7_get_current_var key='title'"]
The value it spits out instead of the title, 1260
makes me think it’s returning 1
as some truthy value and then the post id 260
.
Let me take a look at some past code I’ve done and more into the Kadence theme since the popup seems to be something referred to as the conversion overlay. Perhaps however Kadence is rendering the content of the popup is affecting the global post variables.
Oh! You know what! I think it’s your permalinks.
In your WordPress backend, go to Settings > Permalinks and change the value to anything other than Plain and then click Save Changes. Refresh your product page and see if the product title appears then.
As for the image, it looks like you’re trying to display it as well as putting it in the email. In that case, you’ll want a hidden field to pass on the image’s URL into the email as well as a custom form tag to display your content.
In the form template, you’ll want something like this:
[dynamic_hidden featured_image "CF7_get_attachment size="full""]
[precisionset_image]
The first line is the URL that you’ll use in the email, the second is a custom form tag you’ll create in the next step.
In your child theme’s functions.php file or in a code snippet, plop this in:
/**
* Add custom form tag to Contact Form 7
*
* @return void
*/
function precisionset_add_cf7_shortcodes() {
wpcf7_add_form_tag(
array('precisionset_image'), // Form tag
'precisionset_image_shortcode', // Callback
array('name-attr' => false) // Features
);
}
add_action('wpcf7_init', 'precisionset_add_cf7_shortcodes');/**
* Form Tag Handler for Image Display
*
* @param WPCF7_FormTag $tag Current Contact Form 7 tag object
*
* @return string HTML output of the form tag
*/
function precisionset_image_shortcode($tag) {
// Use DTX helper function to get the attachment id
$featured_image_id = wpcf7dtx_get_attachment(array(
'return' => 'id'
));
// Bail if not found
if(!$featured_image_id) return '';
// Return the image HTML using WordPress core function
return wp_get_attachment_image($featured_image_id, 'thumbnail');
}
This makes it so the featured image is displayed where you place [precisionset_image]
in your form template.
Now over in your Mail template, do what you were trying to do in the Form template but use your hidden field like so:
<img src="[featured_image]" alt="[product_name]" >
Let me know if that works!