I have a html code like this on a Wordpress page:
<a href="mailto:test@wb.nl?subject=taalfouten">test@wb.nl</a>
What I want to achieve is to add the page-title or url as a variable in the email subject. Is that at all possible?
Try this,
<?php
$pagename = get_query_var('pagename');
// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
if ( !$pagename && $id > 0 ) {
$post = $wp_query->get_queried_object();
$pagename = $post->post_name;
} ?>
<a href="mailto:test@wb.nl?subject='<?php echo $pagename ?>'">test@wb.nl</a>
this is for displaying page title which is worked for me, Similarly for URL
$pageurl = $_SERVER['REQUEST_URI'];
<a href="mailto:test@wb.nl?subject='<?php echo $pageurl ?>'">test@wb.nl</a>