Here’s the answer:
Load wp_get_document_title(); into a variable.
Use ‘rawurlencode’ on the variable.
Also, apparently one can use a ” , ” to join to strings and not just ” . “
global $wp;
$url = home_url( $wp->request );
$page_title = wp_get_document_title();
?>
<?php
echo '<p class="side-bar-buttons"><i class="fa fa-envelope" aria-hidden="true"></i> ';
echo '<a href=mailto:?subject=" , rawurlencode($page_title);
echo "&body=' . $url;
echo '>Email This Page</a></p>';
?>```
Related Posts:
- Encode text string being appended as query to URL [closed]
- Syntax error, unexpected ‘class’ (T_CLASS) on line 1 after upgrade to php 5.6.4
- Is sanitize_title_with_dashes formatting function too liberal (in terms of accepted characters)?
- Plugin won’t output characters with diacritics properly
- Issue with json decode in WordPress – value is not returning consistently
- Encoding video without exec function
- Strange special character/Latin characters
- js code not stored in database currectly
- How to check if a string is a valid URL
- Pass media upload value to input field
- What does the token %1$s in WordPress represent [closed]
- Experiences with compiling WordPress using Hip Hop?
- WordPress redirect to landing page if not logged in
- PHP/Manual use of images? – 2 Questions
- Debugging upload problem: What part of WP does actual image-resizing?
- Remove class that has been added by parent theme
- How to use a frontend URL with a Plugin
- Get list of shortcodes from content
- Adding Google Analytics code to the tag of specific pages
- Site Health : An active PHP session was detected
- Custom image upload
- How to scale image with equal width and height without distortion?
- Create Logout Link WordPress Admin Menu
- PHP 5.5, w3 Total Cache, and opcache [closed]
- PHP in post content [closed]
- Display post image with fancybox
- Attaching a pdf to Contact Form 7 e-mail via functions.php [closed]
- WordPress – how to replace with string on the_content() in single.php
- Getting array of customizer settings
- Ajax – Call to undefined function get_option()
- Display PHP within HTML values
- Is there a WordPress version that is incompatible with PHP 5.3?
- WordPress 3.2 query_posts and pagination, permalinks issue
- User management system similar to wordpress one?
- Ajax random number always the same
- How to change the oembed “type”?
- Modify user profile data through scripting?
- wordpress + woocommerce display product with additional information [closed]
- get_children displaying images removed from the page
- Post repeating with infinite scroll
- running arbitrary php files
- WordPress Ajax Call inserting data but success response false
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Loading php file with AJAX in WordPress frontend
- Asynchronous multiple requests 401 Unauthorized
- Get the URL of the page from which an ajax request has been launched within ajax callback
- Using data sent via AJAX in multiple functions on a WP plugin
- WordPress archive page showing 404 Error [duplicate]
- Division by zero error in image.php
- Utilize Function in Child Theme / Template File
- How to have different header.php based on the user logged in?
- How do I include SVG file used as featured image?
- Return product description
- is_page_template showing partial results
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Adding regular php file to site
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- REST API works in browser and via AJAX but fails via cURL
- How to display different submenus?
- Remove slugs from custom posts type
- Unable to access WordPress functions from functions.php
- Simple jQuery AJAX Request fails to run PHP Script
- Pass important values server-side when processing form
- Wp_editor doesn’t send the required data
- pass html code to worpdress
- AJAX function not working [closed]
- Can ‘Custom Field’ data be inserted into this Short Code?
- Free search and custom taxonomy query not providing the same result
- Merge 2 product attribute terms
- WordPress api post image raw data without being blank in media library
- Run do_shortcode on php template using JS function
- global $product is empty string when passed into function
- How to update custom fields when post is published?
- Shortcodes not processing inside post content
- Gravity Forms: How to add PHP function to confirmation conditional shortcode?
- wpdb->query returns different value to phpMyAdmin
- Trouble Accessing Gravity Forms API (GFAPI)
- get_filtered_term_product_counts – Get product terms if any products
- How to Protect a private folder inside uploads folder, if User is not Logged In?
- Add a default style if no Featured image is selected
- Premature end of script headers: wp-mail.php?
- When to use wp_register_script() function?
- setcookie() issues on running with HTTPS on WordPress
- loading a php file to a specific page id
- Getting error in sql query
- How can I enqueue comment-reply script only on certain page?
- Querying posts from wordpress with 2 or more conditionals
- Importing demo data in Multisite
- Count posts per post-type for last month/week
- Posts with Custom Fields does not appear
- How to export database correctly for local to online
- Conditional in foreach loop is outputting content twice
- Replace TinyMCE with Custom Built Editor
- Setting field not saving on front-end
- Particular meta tag – viewport – insertion when dealing with plugin
- Getting custom field data from cart page to checkout page in woocomerce [closed]
- php grabbing every post made?
- How to conditionally concatenate and translate two very long strings?
- How to limit the number of posts in the wordpress loop in conjunction with the “download more” button?
- WordPress Query – Blog Cards Duplicate issue