Current path on page in functions.php

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

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

Share Improve this question edited Apr 16, 2013 at 10:44 tfrommen 9,2317 gold badges40 silver badges59 bronze badges asked Apr 16, 2013 at 10:23 user31579user31579 111 silver badge2 bronze badges 2
  • 1 Do you mean parse_url( $_SERVER['REQUEST_URI'] )? – fuxia Commented Apr 16, 2013 at 10:28
  • 1 Do you want to get path or URl of page? – Vinod Dalvi Commented Apr 16, 2013 at 10:29
Add a comment  | 

1 Answer 1

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

相关推荐

  • Current path on page in functions.php

    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

    21小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信