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:
- Is it safe to pass directory path to plugins_url()?
- plugins_url(”,__FILE__) != WP_PLUGIN_URL with sym links
- Are there functions for file paths, instead of just urls
- Is there a way to embed an iframe in an email with text that updates?
- Is there a way to send HTML formatted emails with WordPress’ wp_mail() function?
- How to call images from your plugins image folder?
- Posts URL structure like site.com/category/the-post-title
- how to set from address according to the form input email address for wp_mail()?
- Using WordPress templating for HTML emails
- Add forward slash on categories url (serve one version of a url)
- Security in WordPress plugin development
- Mail will not send in HTML
- Create custom welcome email without a plugin
- Include HTML template file in wp_mail
- Send an email that contains a HTML and plain text part
- Send batch of posts as HTML Email?
- URL rewriting for WordPress Network (Multisite) subsite
- plugin_dir_url() adds path to url
- Set content type to HTML for lost password email only
- Dropzone.js and wordpress plugin
- plugins_url() incorrectly returns a url with www subdomain
- Woocommerce HTML email option unavailable
- URL parsing – what is it?
- Components used in Themes and Plugins: How to get file URL?
- wp_mail not sending
- Is there a way to dynamically get URL as a path to plugin root, not a local path?
- WP mail sent to MS Exchange recipients = occasional email corruption?
- plugins_url() incorrectly returning wp-include directory
- Does anyone know a plugin that turns a ‘post’ into an html newsletter?
- Unable to send custom welcome email after user register
- Why WordPress plugin url ajax doesn’t work?
- How to set wp_editor to be email friendly?
- Sending HTML emails via wp_mail not working properly
- Access bloginfo, get_option, and plugins_url from a non-core php file
- check if a file in a plugin folder exists from a locale installation
- What’s wrong with my use of plugin_url()?
- Is it possible to send blog posts via email to subscribers?
- PHP form is not sending mail if I use mime type and version in header. How to solve this? [closed]
- HTML email sent with wp_mail shows plain text
- wp_mail strips out the link url from the anchor tag in mail content
- plugins_url() works everywhere but wp_reqister_script()
- Woocommerce Email show HTML source code [closed]
- Getting back a permalink from custom url
- 404 when enqueue_script using plugin_url
- Getting image in mail
- php – Plugin/theme relative PATH/URI
- Add URL Rewrite Rule To WordPress
- Sharing /wp-content/ folder between different WordPress Multisite installs?
- Generate Email Newsletter HTML from Posts published within a Date Range?
- How do I link an image in my plugin so it displays on WordPress?
- How To Style Links in Content Area With Tag Automatically?
- reCAPTCHA on page template without plugin
- Images in wp_mail not showing
- Make custom system url
- Programming WordPress to send a custom-built form to specified email address
- Use Mail-Tag from Contac Form 7 in a script
- About Custom Email Template Design Responsive
- Fail on admin_enqueue_scripts when I try it to upload a CSS file to my WordPress Plugin
- WordPress new user email formatting issues
- How to add (and change the font of) the short product description to order page and customer’s new order e-mail [closed]
- WooCommerce or any other plugin: Deliver JS and CSS through CDN without using a Plugin
- plugins_url not returning correct directory
- How to encode correclty an url with the char “&” for an email?
- Change default url to plugin custom post type
- daily job to run send email based on user data
- Template included with plugin doesn’t return all posts for custom taxonomy
- add custom entries to menu options
- How to tell if a script is being executed from a plugin, a theme or a child theme in WordPress?
- MailPress plugin: table inline style tag removed when sending the newsletter
- Widget redirecting to home page
- Not able to override pluggable function with a mu_plugin
- How to use plugins_url() inside PHP stylesheet file [duplicate]
- What is the correct way to send multipart email in wordpress?
- Turkish Character Problem on mailing
- How to make a rest style plugin?
- Change from blogger to wordpress
- Send retrieve password notification email with custom HTML email template
- I can’t insert more than one image when creating a custom email
- Automatic short URL in posts
- WP_PLUGIN_URL equivalent
- Send and receive emails with wp_mail() for WP User (like Mailserver)