Reputation: 369
I am trying to add a mailto link to a page created with divi builder. I've added a text module in Divi builder with the following content:
Some text... then please write an email to: <a href="mailto:[email protected]?subject=Please help with " target="_blank" rel="noopener">[email protected]</a>
After "Please help with" I need to insert page title. I've tried <?php echo $product->post->post_title; ?>
and <?php echo woocommerce_template_single_title(); ?>
but no luck so far, it just breaks the page. So my final attempt looked like this:
Some text... then please write an email to: <a href="mailto:[email protected]?subject=Please help with <?php echo $product->post->post_title; ?>" target="_blank" rel="noopener">[email protected]</a>
Thank you in advance for any help
Upvotes: 0
Views: 1545
Reputation: 1104
If you want the page title, you would use the_title()
. You can create a shortcode and use that shortcode in the Divi builder. That may be cleaner.
function namespace_post_title() {
$title = get_the_title();
return $title;
}
add_shortcode( 'namespace_show_title', 'namespace_post_title' );
Then in the Divi builder, use the shortcode we just created:
[namespace_show_title]
Upvotes: 0