WordPress has a built-in variable $pagename
that will give the current page. I am looking for something that will give the full url including the path before the current page. Details below.
I am using a page template to display a folders contents depending on which page someone is on. Right now this method is working for top level paths, but not for anything nested. I understand why it isn't working, but I am not sure how to fix it. Here is an example of what I am doing now:
$dir = "wp-content/uploads/Docs/".$pagename;
So that will give me the correct path to the top level pages, but anything below them will not work. I know the easy solution would just to keep all folders at the base level in the upload directory, but I want my server side files to make sense also. How a url using $pagename
looks now:
example.com/accounting
But lets say that I have a page within /accounting like this:
example.com/accounting/accounts-receivable
Using the $pagename
method will only provide me with this:
example.com/accounts-receivable
My preferred solution would be to use something like $pagename
and get the full path. I have looked in the Codex for a solution, but I am either not seeing it or it is not in there. I am specifically looked through the global variables (http://codex.wordpress.org/Global_Variables) to see if there is one. In that Codex page they do not mention their $pagename
variable although it does exist. Hopefully there is a similar variable for the full path.