With this code, a [geturl] shortcode will be created. This shortcode shows the current page full URL address:
add_shortcode ('geturl', 'get_current_page_url');
function get_current_page_url() {
$pageURL = 'http';
if( isset($_SERVER["HTTPS"]) ) {
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
My problem is that it contains the base url. Example, i have one test1 folder and there is one another page (test2): www.test.com/test1/test2 On this page, the shortcode will show this: www.test.com/test1/test2 But I want to remove the base url: and the code should only show the parts after the baseurl. So what I want the code to show is: /test1/test2
Is it possible?