Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Insert Current URL into MailTo link in wordpress

You are overkilling the idea of the query to get the url.

The simplest way and best way at the same time is:

<?php

    // get_the_ID() will return the current's post id
    // get_the_permalink() will return the current url
    $current_url = get_the_permalink(get_the_ID());

?>

That function will not echo, but rather return/get the permalink url for you. You can then incorporate the url by adding

...stuffbeforeurl<?php echo $current_url; ?>...stuffafterurl

into your link.

Related Posts:

  1. Is it safe to pass directory path to plugins_url()?
  2. plugins_url(”,__FILE__) != WP_PLUGIN_URL with sym links
  3. Are there functions for file paths, instead of just urls
  4. Is there a way to embed an iframe in an email with text that updates?
  5. Is there a way to send HTML formatted emails with WordPress’ wp_mail() function?
  6. How to call images from your plugins image folder?
  7. Posts URL structure like site.com/category/the-post-title
  8. how to set from address according to the form input email address for wp_mail()?
  9. Using WordPress templating for HTML emails
  10. Add forward slash on categories url (serve one version of a url)
  11. Security in WordPress plugin development
  12. Mail will not send in HTML
  13. Create custom welcome email without a plugin
  14. Include HTML template file in wp_mail
  15. Send an email that contains a HTML and plain text part
  16. Send batch of posts as HTML Email?
  17. URL rewriting for WordPress Network (Multisite) subsite
  18. plugin_dir_url() adds path to url
  19. Set content type to HTML for lost password email only
  20. Dropzone.js and wordpress plugin
  21. plugins_url() incorrectly returns a url with www subdomain
  22. Woocommerce HTML email option unavailable
  23. URL parsing – what is it?
  24. Components used in Themes and Plugins: How to get file URL?
  25. wp_mail not sending
  26. Is there a way to dynamically get URL as a path to plugin root, not a local path?
  27. WP mail sent to MS Exchange recipients = occasional email corruption?
  28. plugins_url() incorrectly returning wp-include directory
  29. Does anyone know a plugin that turns a ‘post’ into an html newsletter?
  30. Unable to send custom welcome email after user register
  31. Why WordPress plugin url ajax doesn’t work?
  32. How to set wp_editor to be email friendly?
  33. Sending HTML emails via wp_mail not working properly
  34. Access bloginfo, get_option, and plugins_url from a non-core php file
  35. check if a file in a plugin folder exists from a locale installation
  36. What’s wrong with my use of plugin_url()?
  37. Is it possible to send blog posts via email to subscribers?
  38. PHP form is not sending mail if I use mime type and version in header. How to solve this? [closed]
  39. HTML email sent with wp_mail shows plain text
  40. wp_mail strips out the link url from the anchor tag in mail content
  41. plugins_url() works everywhere but wp_reqister_script()
  42. Woocommerce Email show HTML source code [closed]
  43. Getting back a permalink from custom url
  44. 404 when enqueue_script using plugin_url
  45. Getting image in mail
  46. php – Plugin/theme relative PATH/URI
  47. Add URL Rewrite Rule To WordPress
  48. Sharing /wp-content/ folder between different WordPress Multisite installs?
  49. Generate Email Newsletter HTML from Posts published within a Date Range?
  50. How do I link an image in my plugin so it displays on WordPress?
  51. How To Style Links in Content Area With Tag Automatically?
  52. reCAPTCHA on page template without plugin
  53. Images in wp_mail not showing
  54. Make custom system url
  55. Programming WordPress to send a custom-built form to specified email address
  56. Use Mail-Tag from Contac Form 7 in a script
  57. About Custom Email Template Design Responsive
  58. Fail on admin_enqueue_scripts when I try it to upload a CSS file to my WordPress Plugin
  59. WordPress new user email formatting issues
  60. How to add (and change the font of) the short product description to order page and customer’s new order e-mail [closed]
  61. WooCommerce or any other plugin: Deliver JS and CSS through CDN without using a Plugin
  62. plugins_url not returning correct directory
  63. How to encode correclty an url with the char “&” for an email?
  64. Change default url to plugin custom post type
  65. daily job to run send email based on user data
  66. Template included with plugin doesn’t return all posts for custom taxonomy
  67. add custom entries to menu options
  68. How to tell if a script is being executed from a plugin, a theme or a child theme in WordPress?
  69. MailPress plugin: table inline style tag removed when sending the newsletter
  70. Widget redirecting to home page
  71. Not able to override pluggable function with a mu_plugin
  72. How to use plugins_url() inside PHP stylesheet file [duplicate]
  73. What is the correct way to send multipart email in wordpress?
  74. Turkish Character Problem on mailing
  75. How to make a rest style plugin?
  76. Change from blogger to wordpress
  77. Send retrieve password notification email with custom HTML email template
  78. I can’t insert more than one image when creating a custom email
  79. Automatic short URL in posts
  80. WP_PLUGIN_URL equivalent
  81. Send and receive emails with wp_mail() for WP User (like Mailserver)
Categories plugins-url Tags html-email, plugins-url
WP Multisite child theme: get_template_directory_uri() seeks it’s own subdirectory instead of directory of parent theme
Use posts from old db by changing prefix

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress