How can I get the current path of my page?
I know how to do it inside a template file, but I need it inside functions.php
.
And it has to be before the send_headers
hook, because I'll use this info to set a cookie.
I tried using PHP, but I'm getting /wp-admin
How can I get the current path of my page?
I know how to do it inside a template file, but I need it inside functions.php
.
And it has to be before the send_headers
hook, because I'll use this info to set a cookie.
I tried using PHP, but I'm getting /wp-admin
1 Answer
Reset to default 1//get current page's path
$pagePath = parse_url( $_SERVER['REQUEST_URI'] );
$pagePath = $pagePath['path'];
$pagePath = substr($pagePath, 1, -1);//remove slashes
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744489816a4576778.html
parse_url( $_SERVER['REQUEST_URI'] )
? – fuxia ♦ Commented Apr 16, 2013 at 10:28