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.
And it has to be before the send_headers hook, because I’ll use this info to set a cookie.

Read More

I tried using PHP, but I’m getting /wp-admin

Related posts

Leave a Reply

1 comment

  1. //get current page's path
    $pagePath = parse_url( $_SERVER['REQUEST_URI'] );
    $pagePath = $pagePath['path'];
    $pagePath = substr($pagePath, 1, -1);//remove slashes