Does any one knows how to get URL of the page which the given template is assigned to.
Ex :
Template name : tpl_gallery.php (Question)
Url : gallery.html (Answer should be)
More explanation:
function getTplPageURL($TEMPLATE_NAME){
$url;
//Code which i need
return $url;
}
I changed this function a bit because it did not work for me:
Now works for me fine on wordpress 4.9.4
What it sounds like you’re after is get_page_link(), which is described in more detail here:
http://codex.wordpress.org/Function_Reference/get_page_link
If you use this inside the loop of your template it will give you the URL of the page you’re on.
edit: okay, I misunderstood the request. Here’s another approach based on this answer from the WP StackExchange: https://wordpress.stackexchange.com/a/39657
Working example: 2022
thanks to TJ Nicolaides