Hello fello WordPressers,
I’m in a scenario where I need to send the post tile in mails sent from a CF7 form. Normally, you would use the \[\_post\_title\] tag to do this, but here, that tag returns empty, probably because
* the form is not inside the post content
* the post is a custom post type
I’ve found an official script to add custom shortcodes to mail sent by CF7.
I’ve set up the shortcode like this:
add_shortcode(“post_title”, “get_the_title”);
This is tested and works anywhere on the page.
Then, this is the script to add custom tags in CF7 emails:
function my_special_mail_tag($output, $name, $html)
{
if (“post_title” == $name) {
$output = do_shortcode(“[$name]”);
$output .= “: the shortcode was found.”;
}
return $output;
}
add_filter(“wpcf7_special_mail_tags”, “my_special_mail_tag”, 10, 3);
Also tested, however,
$output = do_shortcode(“[$name]”);
always returns empty. I’m only getting the test output: “: the shortcode was found.”
Any help in getting the post title in those mails would be greatly appreciated 🙂
[ad_2]