Here is a handy snippet with which you can easily get current page URL on your WordPress website. It doesn’t matter if you need it on single post, page, home, category, tag, custom post type or any other WordPress template.
You can use this piece of code inside any template on your WordPress website:
$current_url = home_url(add_query_arg(array(),$wp->request));
That’s it, feel free to try!