How to use get_permalink function in WordPress to get the current page URL, including query string?
P粉404539732
2023-08-30 17:13:25
<p>I'm trying to use the get_permalink function to display the current post/page URL on the frontend. The following code runs fine but does not print the query string. How to display the full URL including the query string? </p>
<pre class="brush:php;toolbar:false;">// Short code: [current-url]
function current_url() {
return get_permalink($post->ID);
}
add_shortcode( 'current-url', 'current_url' ); ```</pre></p>
use this code for it